38 users online (0 members and 38 guests)  


  Results 1 to 3 of 3

Related

  1. validating the checkbox,list/menu..    Forum: Javascript Forum
    Replies: 8
  2. validating a form    Forum: Javascript Forum
    Replies: 1
  3. CSS not validating    Forum: CSS Forum
    Replies: 2
  4. Replies: 5
  1. #1
    JPhilS's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2007
    Posts
    4

    Re: Validating Integer in Javascript

    good day...i have a problem in validating integer in my page. i want to validate the input if it is an integer then true... and if not, message should pop out say "Enter a number only".
    my form is this;
    <form name="mainform" action="<? PHP_SELF; ?>">
    <input type=text name="num" >
    <input type=submit name="sub" value="Submit">
    </form>
    it would be very useful for me if you will help me to solve my problem. God Speed!

  2. #2
    ashrafweb's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2007
    Posts
    1

    Re: Validating Integer in Javascript

    java script is the best solution

  3. #3
    redlorry919's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    4

    Re: Validating Integer in Javascript

    Run this JS onSubmit of the form:
    HTML Code:
    var strValue = document.formName.textFieldName.value;
    var fValue = parseFloat( strValue );
    
    if ( isNaN( fValue ) )
    {
    alert( "Please enter a valid number!" );
    }

    Remember also to validate using php. Since Javascript is client side, it can easily be bypassed.



Tags for this Thread