How to check give value is number or character or string in jQuery?



Check whether given value is number or character or string?


<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>

 
<script type="text/javascript">
$(document).ready(function(){
$("#btn").click(function(){
var y = $("#number").val();
if(y>0 || y==0)
{
alert("You entered number");
}
else if(y.length > 1)
{
alert("you entered string");
}
else
{
alert("you enterd charcter");
}

});

});

</script>
</head>

<body>
<div>
<h2>Check Whether number or string</h2>
<input type = "text" id = "number" placeholder="Enter your value" >

<p id="demo"></p>
<button id="btn">Try it</button>
</div>
</body>
</html>





Comments

Popular posts from this blog

Php Form validation with Error messages with Checking fields.

Simple calculator using JQuery and HTML..

how to customize dashboard in active admin gem in rails 4