simple numeric validation in jquery for input -


can me simple jquery numeric validation?

<input type="text" name="yourphone" id="yourphone" required style="border-radius:6px; border:1px solid #ccc; width:300px; height:25px;" /> <input type="submit" value="send inquiry" class="button" id="mysubmitbutton" /> 

you can change input type number <input type="number"... (although not browsers support html5 input types).

or can use this:

$('#myform').on('submit', function(){     var value = $('#yourphone').val()     return $.isnumeric(value); }); 

but phone numbers can complex, not numbers.

in case user uses + ( ) - . , can use this:
(demo)

$('#myform').on('submit', function(){     var value = $('#yourphone').val()     var regex = new regexp(/^\+?[0-9(),.-]+$/);     if(value.match(regex)) {return true;}     return false; }); 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -