www.webdeveloper.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2012
    Posts
    92

    validate text field as user types

    I am trying to validate a text field content as the user types, instead of when they click out of it. here is what i had before

    Code:
    onblur="javascript: validate(this.value, this.id, 1);"
    then i tried this

    Code:
    onkeydown="javascript: validate(this.value, this.id, 1);"
    here is some of the function


    Code:
    function validate(input, name, step) {
     if(step==1) {
     if(name=='name') {
     if (input==null || input=='') {
     document.getElementById('nameDiv').style.visibility='visible';
     document.getElementById('next').disabled='disabled';
     return false;
     } else {
     document.getElementById('nameDiv').style.visibility='hidden';
     var emailField = document.getElementById('email').value;
     if(emailField!="" && emailField!=null) {
     document.getElementById('next').disabled='';
     }
     }
     }
    //and so on..

  2. #2
    Join Date
    May 2006
    Location
    Russia, Rostov-on-Don
    Posts
    1,239
    and...?
    use [code]YOUR CODE GOES HERE[/code] or burn in Hell

  3. #3
    Join Date
    Nov 2010
    Posts
    956
    I think onkeyup would make more sense, considering...

  4. #4
    Join Date
    Apr 2012
    Posts
    92
    sorry. i would like to validate the form as the value changes as the user types in the text field. no when they click out of the field.

  5. #5
    Join Date
    May 2006
    Location
    Russia, Rostov-on-Don
    Posts
    1,239
    agreed with xelawho, onkeyup is what you need.
    use [code]YOUR CODE GOES HERE[/code] or burn in Hell

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •  
HTML5 Development Center



Recent Articles