Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6957353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:59:26+00:00 2026-05-27T14:59:26+00:00

I wrote a jquery plugin for validating forms. It bounds itself to the $(‘element’).Submit

  • 0

I wrote a jquery plugin for validating forms. It bounds itself to the $(‘element’).Submit event to trigger the validation (the bind is inside the plugin). Somehow like this:

// pseudocode
jquery.rdy {
       $('form').validate(); //binding the plugin
}

Inside of the validate plug I bind the validation to the submit

//pseudocode
[...]
$().submit(function () {
    validating... //returning true/false

    if (false) {
        return false //prevent submit form
    }
}
[...]

So and now my question is how can I bind (in other js scripts for example) other stuff to the submit but just if a validation is done.

so like this

$('form').submit(function () {
    if (validate plugin was executed) {
        //do stuff like check if validation was returning a true and now do something else
    }
}

Hopefully I descriped it right …my english is not the best but I tryed to be as concrete s possible (and i hope, pseudocode is a right approach as well)

// EDIT: make the problem more concrete:
I’m trying to figure out a way to solve the following problem: (its very out of the context but the problem is exactly there..)
I have a submit event which is doing something depending on some code triggered in a another decleration.

$('element').submit(function () {
    if ($(this).hasClass('foo')) {
        // do something
    }
});

$('element').submit(function () {
    $(this).addClass('foo');
});

And now the first function is doing nothing cause it has been triggered before the second one. Is there a clean way to solve this. Maybe I need a timeout event (even I hate them)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:59:26+00:00Added an answer on May 27, 2026 at 2:59 pm

    You can bind more functions to the form element with custom names.

    $('form').bind('after_validation',function(){ console.log('hello'); });
    

    And trigger them in your submit form function when you need it:

    $('form').trigger('after_validation');
    

    http://api.jquery.com/trigger/


    Update:

    You cannot change the order of your bound submit events without removing them .unbind('submit') and re-applying in the correct order. What you can do is use custom binds (see above) and trigger them exactly when you need it – like.. inside the submit function.

    $('form').submit(function () {
        //run validation
        $('form').trigger('validation');
    
        //did it pass validation?
        if($(this).data('invalid')){
            console.log('did not pass validation');
            return false;
        }
    
        //passed validation - submit the form
        return true;
    });
    
    //add validation to the "form"
    $('form').bind('validation',function () {
    
        //do validation on form...
    
        if(false){
            $(this).data('invalid',true);
        }
    });
    
    
    
    //add another validator to the form, etc.
    $('form').bind('validation',func...
    

    Im using .data() to store variables to the ‘form’ element so you can access them down the chain.

    This is the basis of what you need and can be applied to a custom jquery plugin to form custom named functions. eg. $().validator().

    http://docs.jquery.com/Plugins/Authoring

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working with the jQuery Validation plugin and I wrote the following code which
I'm using the jQuery Validation plugin on my forms. I have some groups of
I wrote a simple jquery validation plugin for learning puposes, and it works fine.
I am using jQuery Validation Plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) I have wrote following rule jQuery.validator.addMethod(valueNotEquals, function(value,
I wrote a jQuery plugin that binds to 8 elements on a page, and
In the jQuery Validation plugin there are a couple of methods that do the
I wrote the following (part of a jQuery plugin) to insert a set of
I found the jquery validation plugin ( http://plugins.jquery.com/project/validate ) and thought that this would
I use the JQuery Validation plugin to validate a form ( http://docs.jquery.com/Plugins/Validation/ ) For
I wrote a beginner jQuery plugin which validate a form. this jQuery Plugin show

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.