jquery - Validating Contact Number in javascript -


I have a text box and my form is like this:

  & lt ; Input type = "text" name = "ncctact" placeholder = "new contact number" id = "txtNewContact" /> & Lt; Div id = "divCheckContact" & gt; Now on every key press of a key in the NCCTact, I have to check whether the value entered is a number or not, and this is also 10 digit number. And display the message in Disease   

P>

How to do this Please help.

You do this by doing a pattern and title To:

  & lt; Input type = "text" pattern = "\ d {10}" title = "type 10 points please" />   

will check the number of the above 10 digits and if this is not valid then the title will be displayed.

Note: This is part of html5 spec. IE 9 will not work for and below.

You can also do this in pure JS:

  var elem = document.getElementById ('txtNewContact'); Elem.onkeydown = function () {if /! D {10} /. Test (elem.value)) {Warning ("Type 10 points please"); }}    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -