Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Closed Thread
jQuery Form Validation only works on page load
Old 08-29-2009, 02:32 PM jQuery Form Validation only works on page load
Average Talker

Posts: 19
Location: Canada
Trades: 0
Hi,

I've been writing a site, with many forms, and wanted to validate the forms with jQuery, before submitting the form. So, I've been using this: http://docs.jquery.com/Plugins/Validation plugin to do the validation. It works, if I call the script on the initial page load; for example:

Code:
<form> random stuff </form>
<script>
$("form").validate();
</script>
However, there are some pages with multiple forms, but only one form needs to be validated, so I wrote the following script:

Code:
$(document).ready(function(){

    $("form").click(function() {


        //check to see if a form has been validated on the page already, or not:
        if(!formValidation)
        {
            //if mulitple forms, the id of the form will have been set, and we can validate a single form:
            if(this.id != "")
                $("form#"+this.id).validate();
            //if no id has been set on the form, validate every form on the page:
            else
                $("form").validate();
        
            //stop another form from being validated, when its clicked on.
            formValidation = true;
        }
    });
});
However, the form validation does not occur; the page will submit regardless of the state of the form.

Anyone have any ideas? Any help is very much appreciated.

Thanks a lot,
Scott
scott_g is offline
View Public Profile
 
 
Register now for full access!
Closed Thread     « Reply to jQuery Form Validation only works on page load
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15135 seconds with 12 queries