ballouta Posted June 12, 2008 Share Posted June 12, 2008 Hello I have an html form named 'frm' and a javascript functions for this form validation. The validation is working on email address field, user name and password etc.. expect the phone number field named 'mobile' The phone number should always be 6 digits. this is part of my javascript file function isReady() { // check if the First Name is valid if (isProper(frm.fname.value) == false) { alert("Please enter your First Name"); return false; } // check if the email address is valid if (isEmail(frm.email.value) == false) { alert("Please enter a valid email address"); return false; } // check if the mobile is valid if (ismobile(frm.mobile.value) == false) { alert("Please enter a valid mobile number"); return false; } }//funncion isReady() function ismobile(string) { if (string.length !=6) return false; return true; } The problem is in the function ismobile(string) Please help Quote Link to comment Share on other sites More sharing options...
zenag Posted June 12, 2008 Share Posted June 12, 2008 open and close braces for if statement if (string.length !=6) { return false; } return true; Quote Link to comment Share on other sites More sharing options...
ballouta Posted June 12, 2008 Author Share Posted June 12, 2008 Hi I replaced the function with this one but the form still NOT validating the mobile field. http://www.gsclonline.org/register.htm Another question: Does this function validates the input if it is numbers or not? thanks alot Quote Link to comment Share on other sites More sharing options...
zenag Posted June 12, 2008 Share Posted June 12, 2008 script to validate 10 digit number function validateNumber(field, msg, min, max) { if (!min) { min = 10 } if (!max) { max = 10 } if ( (parseInt(field.value) != field.value) || field.value.length < min || field.value.length > max) { alert(msg); field.focus(); field.select(); return false; } return true; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.