•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,695 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,165 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1558 | Replies: 5
![]() |
•
•
Join Date: Oct 2006
Posts: 15
Reputation:
Rep Power: 2
Solved Threads: 0
I'm trying to validate some fields in my form but can't get it to work. I think it's because of the submit button code. Could someone please help identify the problem?
<script language="JavaScript">
function validate_form ( )
{
if ( document.leaveform.dc1.value == "" )
{
alert ( "Please select start date" );
valid = false;
return valid;
}
}
<input name="b1" type="button" value="Submit Without Preview"
ONCLICK ="this.form.action ='fastsaveregistrationdetails.jsp';this.form.submit()"> Last edited by tgreer : Oct 27th, 2006 at 3:33 pm. Reason: Added code tags. User posted from a keyboard with no apostrophe key - added them.
•
•
Join Date: Oct 2006
Location: Utrecht, The Netherlands
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
try putting it in the form's onsubmit event, like this:
<form onsubmit="return validate_form()">
Hi,
try this Code its working
code given by BudBrocken is right
Best regards,
Rahul
try this Code its working
code given by BudBrocken is right

</head>
<script language="JavaScript">
function validate_form ( )
{
if ( document.leaveform.dc1.value == "" )
{
alert ( "Please select start date" );
valid = false;
return valid;
//document.leaveform.submit();
}
}
</script>
<body>
<form action="fastsaveregistrationdetails.jsp" method="post" name="leaveform" onsubmit="return validate_form()">
<input name="dc1" type="text" />
<input name="b1" type="submit" value="Submit Without Preview">
</form>
</body>Best regards,
Rahul
Last edited by katarey : Oct 27th, 2006 at 3:24 pm.
Freelance Web Designer & Developer
Http//www.Katarey.com
Http//www.Katarey.com
•
•
Join Date: Oct 2006
Posts: 15
Reputation:
Rep Power: 2
Solved Threads: 0
The problem is i cant change the following code as i'm using it for having multiple submit buttons on one form. Please advice on how i can run the validation script based on this. Thank you..
[html]<input name="b1" type="button" value="Submit Without Preview"
ONCLICK ="this.form.action ='fastsaveregistrationdetails.jsp';this.form.submit()">[/html]
[html]<input name="b1" type="button" value="Submit Without Preview"
ONCLICK ="this.form.action ='fastsaveregistrationdetails.jsp';this.form.submit()">[/html]
Last edited by tgreer : Nov 14th, 2006 at 3:18 pm. Reason: Added code tags.
Actually I am not getting your Question, but try this code
feel free to ask or clearify the quetion
Regards,
Rahul
<script language="JavaScript">
function validate_form ( )
{
if ( document.leaveform.dc1.value == "" )
{
alert ( "Please select start date" );
valid = false;
return valid;
document.leaveform.submit();
}
}
</script>
<body>
<form method="post" name="leaveform" >
<input name="dc1" type="text" />
<input name="b1" type="submit" value="Submit Without Preview" onclick="this.form.action ='fastsaveregistrationdetails.jsp';return validate_form()">
</form>
</body>feel free to ask or clearify the quetion
Regards,
Rahul
Freelance Web Designer & Developer
Http//www.Katarey.com
Http//www.Katarey.com
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- asp form action script (Site Layout and Usability)
- In Business Since 95 Provide SEO, Script Installs, Php Work, Forums,eStores and More! (Post your Resume)
- how do I kill a script after a set amount of time? (Perl)
- "How Much Would 'You' Charge?" (Website Reviews)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Javascript Structures?
- Next Thread: Link-style



Linear Mode