Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2006
    Posts
    218
    Thanks
    4
    Thanked 0 Times in 0 Posts

    SubmitHandler and avoided form submission

    I use
    http://bassistance.de/jquery-plugins...in-validation/

    When validation is correct user can refresh page where is confirmation message. As I like to use handler to avoid submitting form values, need help how to do in the correct way.

    Example is like:
    PHP Code:
            // specifying a submitHandler this will submit the form after we have validated ok
            
    submitHandler: function() {


                return 
    false// avoid the actual submit of the form.

            

    Is this technical possible jQuery and handler?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    When you use the submitHandler callback option, you have to call form.submit() to manually submit the form. If you don't call it, then the form will not be submitted.

    Code:
    $(".selector").validate({
      submitHandler: function(form) {
        // do other things for a valid form
    
        form.submit(); //remove this if you don't want to submit the form
      }
    });
    Btw, why are you not submitting the form? Are you using AJAX to submit it?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Regular Coder
    Join Date
    May 2006
    Posts
    218
    Thanks
    4
    Thanked 0 Times in 0 Posts
    PHP Code:

    jQuery
    (document).ready(function() {
        
    // validate signup form on keyup and submit
        
    var validator jQuery("#validationForm").validate({
            
    rules: {
                
    firstname"required",  //Set the first name field to be a required Form

                
    email: {
                    
    requiredtrue,   //Set the e-mail field to be a required Form
                    
    emailtrue,      //Set the e-mail field to be validated as an e-mail address
                
    },

            },
            
    messages: {
                
    firstname"Enter your firstname",
                
    email: {
                    
    required"Please enter a valid email address",
                    
    minlength"Please enter a valid email address",
                }
            },

            
    // specifying a submitHandler this will submit the form after we have validated ok
    jQuery(".selector").validate({
      
    submitHandler: function(form) {
        
    // do other things for a valid form

        
    form.submit(); //remove this if you don't want to submit the form
      
    }
    });

        });


    }); 
    1. Will this work that form values can not be submitted when user refreshes browser as page has confirmation that form is submitted but it should not be sent form when user refreshes.
    2. What is actuall class like .selector

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I don't exactly know what you are trying to do.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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