I have a Javascript code (below) which validates mobile numbers. It's working fine. But the problem I am facing is both valid and invalid mobile numbers are being inserted into the database. I want only valid mobile numbers to be inserted into the database.
The code is as follows. Can anyone suggest any ideas to change the code?
<script type="text/javascript">
function CheckINumber(INumber) {
var INum = /^[+]{1}[0-9]{2}-\d{10}$/;
if(INum.test(INumber)) {
alert("Your Mobile Number Is Valid.");
} else {
alert("Your Mobile Number Is Not Valid.");
}
}
<input name="Upload" type="submit" height="25" class="uploadbutton" onClick="CheckINumber(mobile.value);"