Skip to content
Jony edited this page Jan 10, 2015 · 5 revisions

Subscribe

.on("validition")

After verification each time a field would trigger this event, this event need to bind on the form, you can use this event to verify the results of real-time monitoring of the form.

$("#form").on("validation", function(e, field){
    // if the whole form is valid
    console.log(this.isValid);
    // if the current field is valid
    console.log(field.isValid);
})

.on("valid.form")

Triggered after the form is valid.

$('#form').on('valid.form', function(e, form){
    //do something...
});

.on("invalid.form")

Triggered after the form is invalid.

$('#form').on('invalid.form', function(e, form, errors){
    //do something...
});

.on("valid.field")

Triggered after the field is valid.

$('#username').on('valid.field', function(e, result){
    //do something...
});

.on("invalid.field")

Triggered after the field is invalid.

$('#username').on('invalid.field', function(e, result){
    //do something...
});

.on("valid.rule")

Triggered after the rule is valid.

$('#username').on('valid.rule', function(e, ruleName){
    if (ruleName === 'remote') {
        //do something...
    }
});

.on("invalid.rule")

Triggered after the rule is invalid.

$('#username').on('invalid.rule', function(e, ruleName){
    if (ruleName === 'remote') {
        //do something...
    }
});

Publish

.trigger("validate")

// Verify the selected field.
$('#username').trigger("validate");
// Verify the selected form.
$('#form').trigger("validate");
// Verify the selected area.
$('#area').trigger("validate");

.trigger("showmsg")

// Tips ok message
$("#username").trigger("showmsg", ["ok", "Great name"]);
// Tips error message
$("#username").trigger("showmsg", ["error", "Name is already taken"]);
// Tips general message
$("#username").trigger("showmsg", ["tip", "Others make a good name for you impressed"]);
// Tips tip message has been bound (data-tip)
$("#username").trigger("showmsg", ["tip"]);
// Tips all tip message
$("#form").trigger("showmsg", ["tip"]);

.trigger("hidemsg")

// Hide field message
$("#username").trigger("hidemsg");
// Hide all messages form the form
$("#form").trigger("hidemsg");