Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
 
</head>
  
<body>
  <input type="Text" id="Age" maxlength="3" name="Age" />
  <input type="Submit" value="Submit" id="Submit" />
  <br \>
  <label id="ErrorMessage"> </label>
</body>
</html>
 
$(document).ready(function(){
  $("#Submit").click(function(e){
     var isNumber =   IsNumberOnly('input#Age');
    if(!isNumber)
    {
      e.preventDefault();
      $("#ErrorMessage").text('Invalid value. Please enter numeric value.');
    }
    else
    {
       $("#ErrorMessage").text('Success.');
    }
  });
});
function IsNumberOnly(element) {    
    var value = $(element).val();
    var regExp = "^\\d+$";
    return value.match(regExp); 
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers