www.webdeveloper.com
Results 1 to 4 of 4

Thread: validating form

  1. #1
    Join Date
    Apr 2012
    Posts
    112

    validating form

    I am having trouble validating a form. here is my code:

    Code:
    function checkFields(){
    	if(checkName()){
    		return true;
    	}else{
    		return false;
    	}
    }
    function checkName(){
    	if(condition){
    		// show bad image for status
    		return false;
    	} else {
    		// show good image for status
    		checkFields();
    		return true;
    	}
    }
    
    <input type="text" name="name" id="name" onKeyDown="checkName();" />
    when i type in a valid name, the checkmark next to it appears. but then the checkmark next to the section header is not showing. what could be wrong?

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by droidus View Post
    Code:
     function checkName(){
        if(condition){                               /* What is condition ? */
            // show bad image for status
            return false;
        } else {
            // show good image for status
            checkFields();   /* Function's return value isn't being used*/
            return true;
        }
    }
    when i type in a valid name, the checkmark next to it appears. but then the checkmark next to the section header is not showing. what could be wrong?
    You have shown nothing that might control such a display.

  3. #3
    Join Date
    Aug 2012
    Location
    Belgium
    Posts
    66
    jquery.validate plugin could save you some time here

  4. #4
    Join Date
    Apr 2012
    Posts
    112
    the condition is this:
    Code:
    $('#name').val().length == 0 || $('#name').val().length == 1
    i call on the function to decide whether or not i display the checkmark for the section. it should return to checkName, and then the validation is done until another key is pressed.

Thread Information

Users Browsing this Thread

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

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