![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2005
Posts: 1
Rep Power: 0
![]() |
Help with form validation
I need some help!
Got a simple form, in which a user has to enter an integer. What I want to do is when they hit the "submit" button, for a confirm box to appear, asking if their number is correct (I actually want the value they entered to appear in the confirmation message.) If they are happy, they click ok and the form then submits (by running the script in the target file.) If not, they click cancel, and the page simply stays as it was, so that they can change the value. Got most of this to work, but cant figure out how to actually display the value they enter in the confirmation box message. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Nov 2005
Posts: 122
Rep Power: 3
![]() |
<script type="text/JavaScript">
function checkIt(f)
{
var v=f.elements['val'].value;
var msg='';
msg+='The value you have entered is "'+v+'". Is this correct?';
msg+='\nPress ok to continue, or cancel to go back and change it.';
return confirm(msg);
}
</script>
</head>
<body>
<form name="f1" method="post" action="#" onsubmit="return checkIt(this);">
<input type="text" name="val" />
<input type="submit" />
</form>
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet" |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|