sayedsohail Posted February 16, 2007 Share Posted February 16, 2007 Hi, I don't know where i am wrong, but this functions are not at all verifying the value function checkNumeric( strng ) { var error = ""; var passPattern = new RegExp("/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/"); if(!passPattern.test(strng)) { if(strng == "") { error += "Pleae neter the Phone and Mobile numbers.\n"; } else if((strng.length < 11) || (strng.length > 12)) { error += "The phone number is wrong lenght, it should be 01332600090.\n"; } else { error += "The phone number contains illegal characters.\n"; } } return error; } function checkEmpty(strng) { var error = ""; var strTemp = strng; strTemp = trimAll(strTemp); if(strTemp.length < 1){ error += "Please enter company name.\n"; } return error; } Quote Link to comment Share on other sites More sharing options...
ozfred Posted February 17, 2007 Share Posted February 17, 2007 You need to start by saying what you are testing for. You seem to be testing a phone number, but there are many different formats for that. What are you actually trying to do? Quote Link to comment Share on other sites More sharing options...
sayedsohail Posted February 17, 2007 Author Share Posted February 17, 2007 I wish to validate phone number, address with numbers, letters, whitespaces and commas. That's all i wanted to validate. thanks Quote Link to comment Share on other sites More sharing options...
fenway Posted February 18, 2007 Share Posted February 18, 2007 You should test each part of that regex separately. 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.