Need numeric validation for a field in a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • satyasampan
    New Member
    • Aug 2012
    • 9

    Need numeric validation for a field in a form

    i need to validate the form .. fields should not be empty is justified... but the last field i.e var z should be numeric ..please reply fast

    Code:
    function validateform()
    {
    var x=document.getElementById("nameid").value;
    if(x==''){alert("name should not be empty");return false;}
    var y=document.getElementById("qualificationid").value ;
    if(y==''){alert("qualification should not be empty");return false;}
    var z=document.getElementById("rollnumid").value;
    if(z==''){alert("rollnum should not be empty");return false;}
    }
    Last edited by gits; Aug 16 '12, 07:28 AM. Reason: added code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    you might use the isNaN method for that check

    Comment

    • ariful alam
      New Member
      • Jan 2011
      • 185

      #3
      @satyasampan, you should have a look @ the following link



      Hope works for you. :)

      Comment

      Working...