Hi,I have two functions to validate two inputs (name,email) in a form, the problem is that one function works, and the other doesnt work. What should I add to make them all work?!The first function:
<script type="text/javascript">function validate_required(field,alerttxt){with (field){if (value==null||value=="") {alert(alerttxt);return false}else {return true}}}function validate_form(thisform){with (thisform){if (validate_required(fname,"Name must be filled out!")==false) {fname.focus();return false}}}</script>
The second function:
<script type="text/javascript">function validate_email(field,alerttxt){with (field){apos=value.indexOf("@")dotpos=value.lastIndexOf(".")if (apos<1||dotpos-apos<2) {alert(alerttxt);return false}else {return true}}}function validate_form(thisform){with (thisform){if (validate_email(email,"Not a valid e-mail address!")==false) {email.focus();return false}}}</script>
Finally, the form:
<form action="submitpage.htm" onsubmit="return validate_form(this)"method="post"><input type="text" name="fname" size="20"><input type="text" name="email" size="30"><input type="submit" value="Submit"></form>
Note: The function which is appove the other is the one that doesnt work! means that if I but it below the other code it will work.