SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Why this codes not functioning well?

    Hi guys,

    I have this method below,
    Code:
    		function validate(formData, jqForm, options) { 
    		    // fieldValue is a Form Plugin method that can be invoked to find the current value of a field 
    		    // To validate, we can capture the values of both the username and password 
    		    // fields and return true only if both evaluate to true 
    		 
    		    var title 		 = $('input[name=title]').fieldValue(); 
    		    var url 		 = $('input[name=url]').fieldValue();
    		    var description  = $('input[name=description]').fieldValue(); 
    		 
    		    // usernameValue and passwordValue are arrays but we can do simple 
    		    // "not" tests to see if the arrays are empty 
    		    if (!title[0] || !url[0] || !description[0]) { 
    		        alert('Please enter a value for both Title, URL and Description'); 
    		        return false; 
    		    } 
    		    
    		    return true;
    		}
    The method should validate the three input fields which are the "title", "url" and "description".
    The problem is even thought all fields are filled with value it still show up the alert() message.

    Any help please.

    Thanks in advaned.
    Quality codes are optimized and tested...
    Click here for inspiration..

  2. #2
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    By the way I got that method from this plugin,
    http://www.malsup.com/jquery/form/#validation

    Any help please?
    Quality codes are optimized and tested...
    Click here for inspiration..

  3. #3
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,408
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    There's nothing obviously wrong with the code you posted. The problem is somewhere in the rest of your code. Could you post a link to the page (or, if that's not possible, post the full code of the page here)?


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
  •