Implementation code for Bootstrapvalidator checksum erase reset (recommended) _javascript tips

Source: Internet
Author: User
Tags button type

1. Introduction of CSS and JS

BootstrapValidator.min.css

BootstrapValidator.min.js

The modal code in 2.html

<div class= "Modal Fade id=" Editmodal "tabindex="-1 "role=" dialog "aria-labelledby=" Mymodallabel "aria-hidden=" True "> <div class=" Modal-dialog "> <div class=" modal-content "> <div class=" Modal-header "> < Button type= "button" class= "Close" data-dismiss= "modal" aria-hidden= "true" >x</button> 

3.js code

Save function Saveadmin () {//Open authentication $ (' #saveadmin_form '). Data (' Bootstrapvalidator '). Validate (); 
if (!$ (' #saveadmin_form '). Data (' Bootstrapvalidator '). IsValid ()) {return; //form submission $.ajax {type: POST, DataType: ' json ', url: "<%=request.getcontextpath ()%>/user/saveuser.html?ma=" + Math.random (), data: {"type": "0", "ID": $ ("#adminid"). Val (), "account": $ ("#edit_adminName"). Val (), "Display_name": $ ( "#edit_displayName"). Val (), "Password": $ ("#edit_passwd"). Val (), "Mail": $ ("#edit_Mail"). Val (), "Role": $ ("#edit_ Role "). Val ()," desc ": $ (" #edit_desc "). Val ()}, Success:function (JSON) {json = eval (" +json+ ")); $ (" #editModal ").
Modal ("Hide");
$ ("#dialog_content"). HTML (json.message);
$ ("#dialog_button_queren"). Hide ();
$ ("#dialog_modal"). Modal ("show");
T.ajax.reload (null, TRUE);
}
});
//Initialize form validation $ (document). Ready (function () {formvalidator ();}); /********************************* Checksum reset focus here when modal is hidden, destroy the validation and reload the validation ****************************************/// Modal Verify Destroy refactoring $ (' #editModal '). On (' HiddEn.bs.modal ', function () {$ (' #saveadmin_form '). Data (' Bootstrapvalidator '). Destroy (); $ (' #saveadmin_form '). Data ('
Bootstrapvalidator ', null);
Formvalidator ();
});
Form validation Rule function Formvalidator () {$ (' #saveadmin_form '). Bootstrapvalidator ({message: ' This value isn't valid ', Feedbackicons: {valid: ' Glyphicon glyphicon-ok ', invalid: ' Glyphicon glyphicon-remove ', validating: ' Glyphicon Glyphicon-refresh '}, Fields: {//admin name edit_adminname: {message: ' Admin name validation failed ', validators: {notempty: {message: ' admin name cannot be empty '}, Stringlength: {min:5, max:64, message: ' Administrator name length must be between 6 and 64 '}},//password edit_passwd: {message: ' Password validation failed ', validators : {notempty: {message: ' Password cannot be empty '}, Stringlength: {min:5, max:64, message: ' Password length between 5 to 64 '}/*, identical: {field: ' Ed It_passwd1 ', message: ' Two times password is not the same '}/}},//password confirmation EDIT_PASSWD1: {message: ' Password verification failed ', validators: {notempty: {message: ' Password confirmation cannot be null '}, identical: {field: ' edit_passwd ', message: ' Two times password is not the same '}},//display name Edit_displayname: {message: ' Username authentication failed ', VA LIdators: {notempty: {message: ' Display name cannot be empty '}, Stringlength: {min:5, max:128, message: ' Display name length must be between 6 and 18 bits '}},//mailbox Edit _mail: {validators: {notempty: {message: ' Mailbox cannot be empty '}, EmailAddress: {message: ' mailbox format is correct '}, Stringlength: {max:256, mess Age: ' Mailbox length must be less than 256 '}},//Memo Edit_desc: {message: ' Memo validation failed ', validators: {stringlength: {max:256, message: ' Memo length must be small
To 256 '}}},}}; }

The above is a small set for you to introduce the Bootstrapvalidator checksum verification, verify the implementation code to clear the reset (recommended), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.