JavaScript code for prevent user for enter only numbers

JavaScript code for prevent user for enter only numbers

This is a JavaScript code for prevent user for enter only numbers in text box……

 <html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script>
function Submit(){
fcontact=document.form.contact.value;
 if( fcontact == "" )
   {
     document.form.contact.focus() ;
  document.getElementById("errorBox").innerHTML = "enter the contact number";
     return false;
   }    
}
$(function () {
$('#contact').keydown(function (e) {
if (e.ctrlKey || e.altKey) {
e.preventDefault();
} else {
var key = e.keyCode;
if (!((key == 8) || (key == 32) || (key >= 48 && key <= 57))) {
e.preventDefault();
}
}
});
});
</script>
</head>
<body>
       <form name="form" >
         <div id="errorBox"></div>
        <input type="text" name="contact" value=""  placeholder="Enter Contact" class="input_contact" id="contact">
      <div>
        <p id="sign_user" onClick="Submit()">Sign Up </p>
      </div>
</body>
</html>

Leave a Reply

Related Posts: You may like

How To Create a Modal Popup With CSS and JavaScript

Get Latitude Longitude from Address

cookie policy popup

How to make a sticky sidebar on scroll

PHPKIDA Offering Free Tools:

INSTA DOWNLOADER

Download Instagram Videos & Photos.

Download Now

CURRENCY CONVERTER

Real Time Currency Converter

Convert Now

ROBOST.TXT GEN.

Robots.txt File Creater

Create Now

HTML MINIFIER

Compress yout HTML Code

Minify Now

CSS MINIFIER

Compress yout CSS Code

Minify Now

JAVASCRIPT MINIFIER

Compress yout JavaScript Code

Minify Now

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.