I'm wondering how to validate a form if first checking for data in the text boxes and then also checking for to make sure they match a certain length to be for acceptability.
Code:<script type="text/javascript"> <!-- Hide from non-JavaScript browsers function checkInputs() { if (document.forms[0].address.value == "" || document.forms[0].city.value == "" || document.forms[0].state.value == "" || document.forms[0].country.value == "" || document.forms[0].post.value == "" || document.forms[0].phone.value == ""){ window.alert("Missing data"); return false; } return true; if(document.forms[0].post.length !=5 ) { alert ('Zipcode should be five digits.'); return false;} if(document.forms[0].phone.length !=10 ) { alert ('Phone # should be 10 digits.'); return false;} function confirmReset() { var resetForm = window.confirm("Are your sure you want to reset this form?"); if (resetForm == true) return true; return false; } // Stop hiding --> </script>




Reply With Quote