Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    17
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Validation Script & Error Message Help

    The inputs to the form below is supposed to be validated using the script below. If the user does not use all numbers, a message is supposed to appear next to the "validate" button saying "The input is not numeric." Can someone help me on this?
    Code:
    <form id="form1" name="form1" action="#">
    <table align='center'>
    <td><input name="numeric" id="numeric" validation="required" /><input type="submit" value=" Validate " onclick="IsNumeric();" /></td>
    </table>
    </form>
    
    <script type="text/javascript">
    function IsNumeric(sText) {
    var ValidChars = "0123456789.";
    var IsNumber=true;
    var Char;
    for (i=0;i<sText.length && IsNumber == true; i++) {
    Char = sText.charAt(i);
    if (ValidChars.indexOf(Char) == -1) {
    IsNumber = false;
    }
    }
    return IsNumber;
    }
    </script>
    Last edited by Kor; 07-29-2008 at 04:25 PM. Reason: wrap the code [code][/code], please

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Jun 2008
    Posts
    17
    Thanks
    7
    Thanked 0 Times in 0 Posts
    I just solved my own problem. Thanks to all for looking at this.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •