chet139 Posted April 20, 2008 Share Posted April 20, 2008 Hi, Im using javascript for some basic form validations here what I have so far and it works: function checkFields() //validation to ensure at least one field is populated { // if(cust.custId.value != "" && cust.custTitle.value != "" && cust.custFirstname.value != "" && cust.custSurname.value != "" && cust.propNo.value != "" && cust.propStreet.value != "" && cust.propTown.value != "" && cust.propCounty.value != "" && cust.propPostcode.value != "") { return true; } else { alert("Please Enter the Details"); return false; } } However to this, I would like to add a check for checking the CUSTID id numeric only.I am trying to use the isNAN function somehow but have had no success can anyone help please? For example i tried adding to the end of my IF statement "&& isNAN(cust.custId.value)==false" so if its false the overall check passes. because I want it numeric only whereas isNAn checks if its not numeric. Link to comment https://forums.phpfreaks.com/topic/101970-simple-form-validation/ Share on other sites More sharing options...
epic_era1 Posted April 21, 2008 Share Posted April 21, 2008 Try this it might work, logically it shoud function checkFields() //validation to ensure at least one field is populated { var onlyNumbers =isNAN(cust.custId.value); // if((cust.custId.value != ""&& onlyNumbers=="false") && cust.custTitle.value != "" && cust.custFirstname.value != "" && cust.custSurname.value != "" && cust.propNo.value != "" && cust.propStreet.value != "" && cust.propTown.value != "" && cust.propCounty.value != "" && cust.propPostcode.value != "") { return true; } else { alert("Please Enter the Details"); return false; } } Link to comment https://forums.phpfreaks.com/topic/101970-simple-form-validation/#findComment-522859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.