BootstrapValidator does not trigger verification implementation code, bootstrapvalidator

Source: Internet
Author: User

BootstrapValidator does not trigger verification implementation code, bootstrapvalidator

I. Preface

BootstrapValidator is a jquery Form Verification plug-in based on bootstrap3. It is the most suitable form verification plug-in for the bootstrap framework. You can use this framework in your work to write down your accumulated experiences.

Ii. Problem Description

When the button type is submit, use the isValid () of bootstrapValidator to make the verification form work normally. However, if the type of the button is button, only the isValid () of bootstrapValidator is called () the method cannot work normally. In this case, you need to use the validate () method of bootstrapValidator for activation.

Iii. project code

1. JSP

<Span style = "font-size: 14px; "> <div id =" addAdminDialog "class =" modal fade "tabindex ="-1 "> <div class =" modal-dialog cy-modal-dialog-f "> <div class = "modal-content"> <div class = "modal-header"> <button class = "close" data-dismiss = "modal"> <span> × </ span> </button> 

2. JS

<Span style = "font-size: 14px;"> var faIcon = {valid: 'glyphicon glyphicon-OK ', invalid: 'glyphicon glyphicon-delete', validating: 'glyphicon glyphicon-refresh'} // added the Administrator front-end verification $ ("# addAdminForm "). bootstrapValidator ({message: 'This value is not valid', // feedback icon feedbackIcons: faIcon, fields: {loginName: {message: 'invalid login name', validators: {notEmpty: {message: 'login name cannot be blank '}, StringLength: {min: 5, max: 30, message :' Username length greater than 6 bits and less than 30 bits}, regexp: {regexp:/^ [a-zA-Z0-9 _] + $/, message: 'username can only contain letters, numbers, and underscores '}}}, userName: {message: 'username format incorrect', validators: {notEmpty: {message: 'username cannot be blank '}, stringLength: {min: 6, max: 30, message: 'username length greater than 6 bits and less than 30 bits'}, regexp: {regexp: /^ [a-zA-Z0-9 _] + $/, message: 'user name can only contain letters, numbers, and underscores '}}, password: {validators: {notEmpty: {message: 'mailbox cannot be blank '}, emailAddress: {message:' is not a valid Email Address '}}}}); </span> <span style = "font-size: 14px;"> // adds the operator function addAdmin () {/* manually verify the form when it is a normal button. */$ ('# AddAdminForm'). data ('bootstrapvalidator'). validate (); if (! $ ('# AddAdminForm '). data ('bootstrapvalidator '). isValid () {return ;}$ ("# addAdminForm "). ajaxSubmit ({dataType: 'json', type: "post", success: function (json) {if (json. status = "succ") {doQuery (); Modal. alert ({msg: "operation successful"}); $ ("# addAdminDialog "). modal ('hide ');} else {Modal. alert ({msg: json. msg}) ;}, error: function () {Modal. alert ({msg: "operation failed"}) ;}}</span>

IV,

The above section describes the implementation code of BootstrapValidator that does not trigger verification. I hope it will help you. If you have any questions, please leave a message and I will reply to you in time. Thank you very much for your support for the help House website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.