programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums Hi I need to validate my mobile number it wants to be in 91-1234567890 this format If i enter 1234567890 its wants to show alert message your mobile wants to be in 91-1234567890 format If i enter 9112345678901 its wants to show alert message your mobile wants to be in 91-1234567890 format If i enter 9112345678901 its wants to show alert message your mobile wants to be in 91-1234567890 format and then the correct mobile format 91-1234567890 wants to save in My sql database. If the application is india based then you can proceed with 91 as country code or keep an array of all country codes and change the validation accordingly.
All i can say is investigate regular expressions this is a very simple one Hi Arun Please check this code. Also make use of component level of validation to restrict the user to enter only numerics and characters " " and "-" 2.
Next, we use the Java Script regular expression /\W/ to forbid illegal characters from appearing in usernames.
We want to allow only letters, numbers and underscopes.
For that we use the seacrh() method and two more regular expressions: /(a-z) / and /(0-9)/.
validate Email ( ) Next we want to see if the email address the user entered is real.
Also we will use trim() function that will trim leading whitespace off the string.
This wont be perfect validation it is possible to slip not compliant addresses by it but it's normally good enough.
If the required field is blank, we return the error string to the main function.
If its not blank, the function returns an empty string.
validate Password ( ) The function below checks the password field for blankness and allow only letters and numbers - no underscopes this time.
So we should use a new regular expression to forbid underscopes. Next, we want to permit only passwords that contain letters and at least one numeral.
Otherwise it returns a message describing the error and highlight appropriate element with yellow.