Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 18th, 2005, 1:17 PM   #1
dbounford
Newbie
 
Join Date: Nov 2005
Posts: 1
Rep Power: 0 dbounford is on a distinguished road
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.
dbounford is offline   Reply With Quote
Old Nov 18th, 2005, 2:49 PM   #2
Agent 47
Hobbyist Programmer
 
Agent 47's Avatar
 
Join Date: Nov 2005
Posts: 122
Rep Power: 3 Agent 47 is on a distinguished road
<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>
--47.
__________________
"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"
Agent 47 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:06 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC