Techknow Study

java script {input field should only accept numbers}

6:53:00 PM vikas 0 Comments Category :



WAP in java script to check for input field should only accept numbers.

 Through this program you learn how to make a input field that should only contain the number in his input field. for this we need to write some java script that have given below.
If you ask why this required?.........
yes yes you can ask
the answer of this question is that=>
some where you need to fill only number like
in place of age fill number so you can apply this
script their for client help...

be updated with this blog may be this will helpful
for you

http://www.techknowstudy.com/


Program:-


<html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <title>CLient Side Validation</title>
 <script language="javascript">
 function validation()
 {
if(document.validationform.number.value.match(/^[09]+$/))
//document.formname.name of input .value.match(format)//
{
 alert("YOU HAVE ENTRED VALID INFORMATION");
 return true;
}
 Else
{
 alert("KINDLY ENTER ONLY NUMBERS");
 return false;
                        }
                    }
           
</script>             
  </head>
 <body>
 <h1>VALIDATE</h1>
  <form name="validationform">
  ENTER NUMBER<input type="text" name="number">
  <input type="button" value="submit" onclick="return validation();">
           
 </form>
 </body>
   
</html>

RELATED POSTS

0 comments