This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I am doing java script validation in struts .I am not using validator frame work.And i want to do validation using java script without using validator frame work of struts.But when i run the page on browse its not validationg the page. Please help me. My Code.
<html> <head> <title>JSP for StudRegForm form</title> </head> <body> <script type="text/javascript">
<!-- hide script from older browsers function validateForm(studRegForm) {
if(""==document.forms.contact.fname.value) { alert("Please enter your Father name."); return false; }
if(""==document.forms.contact.address.value) { alert("Please enter your address."); return false; }
if(""==document.forms.contact.dob.value) { alert("Please enter your Date of Birth ."); return false; } if(""==document.forms.contact.currentclass.value) { alert("Please enter Current class."); return false; } if(""==document.forms.contact.name.value) { alert("Please enter Name."); return false; } } stop hiding script -->
This isn't Struts-related, but JavaScript and DOM.
1) You need to use the DOM form element. 2) You need to use the form values from that form element, the JavaScript you show has something called "contact" in it that seems to appear out of nowhere.
I'd recommend searching the web for "javascript form validation".