Results 1 to 2 of 2

Thread: Form Validation - the most popular question of the century!

  1. #1
    Join Date
    May 2010
    Location
    Sacramento, CA
    Posts
    91
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Talking Form Validation - the most popular question of the century!

    hey folks, i'm new js.. i have some forms i'd like to apply this too but realized it doesn't work how i planned. The submit button is disabled until the user enters something in the field. Now if ALL the fields are required, then how can i wait to enable the submit button after ALL the required fields are filled out instead of the submit button being enabled after the first field has something entered into it...

    Code:
    function enableDisableSend(oFld){
    oFld.form.send.disabled = (oFld.value == "") ? true : false;
    }
    HTML Code:
        <input type="text" name="email" maxlength="50" onKeyUp="enableDisableSend(this)" onBlur="enableDisableSend(this)"/>
        <input type="text" name="temp_password" maxlength="16" onKeyUp="enableDisableSend(this)" onBlur="enableDisableSend(this)"/>
        <input type="radio" name="user_type" value="staff" onKeyUp="enableDisableSend(this)" onBlur="enableDisableSend(this)"/> 
        <input type="radio" name="user_type" value="client"  onKeyUp="enableDisableSend(this)" onBlur="enableDisableSend(this)"/>
    
    <input type="submit" name="send" value="Add User" disabled="disabled"/>
    Last edited by crobinson42; 10-06-2011 at 12:27 AM. Reason: changing status to resolved

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Please apply these changes:
    Code:
    function enableDisableSend(oFld){
    document.getElementById('send').disabled = (oFld.value == "") ? true : false;
    }
    
    
    <input type="submit" name="send" id="send" value="Add User" disabled="disabled"/>
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. The Following User Says Thank You to rangana For This Useful Post:

    crobinson42 (10-06-2011)

Bookmarks

Posting Permissions

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