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.
This is a javascript question!!! why are you asking in the database section.
You might get better results asking in a forum where people who know javascript might go.
All i can say is investigate regular expressions this is a very simple one
Note :
1. Also make use of component level of validation to restrict the user to enter only numerics and characters "+" and "-"
2. 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.
Regulare expressions are indeed the way to go for this type of activity. The type of code shown earlier should be avoided when much better alternatives exist.