Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to check value is number or not using Javascript
12-13-2011, 04:31 AM
Post: #1
Thumbs Up how to check value is number or not using Javascript
Java-script is a powerful technique to check certain condition on client-side itself before submitting form to check at server-side,so that time will be saved.
Here we are going to know how to check a value whether it is number or not and no's not more than 6 using javascript.
For ex.You get the value from simple form.

Quote:<form name="f">
<input type="text" name="zip" onblur="return checkzip()"/>
</form>

Write this code before head section
<script type="text/javascript">
function checkzip()
{var StringVar=new String(document.f.zip.value);
var x=StringVar.length;
if(x==6&&!isNaN(document.f.zip.value))
{
return true;
}
else
{
alert("zipcode must be 6 digits") return false;
}
}
</script>


Try this code and do comment we will be happy to hear from you.

Happy coding
Find all posts by this user
Add Thank You Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies Views: Last Post
Question Print a particular area of a page using javascript rajasri 0 306 12-13-2011 04:20 AM
Last Post: rajasri
Lightbulb linking two or more pages from radio button using javascript rajasri 0 167 12-13-2011 04:17 AM
Last Post: rajasri

Forum Jump:


User(s) browsing this thread: 1 Guest(s)


WE will share important jobs and updates on facebook so like us to get updates