Bootstrap Form Verification: formValidation implements remote verification. validation Form Verification

Source: Internet
Author: User
Tags bootstrap website

Bootstrap Form Verification: formValidation implements remote verification. validation Form Verification

Recently, the project used a very powerful form verification. Record. Official Address: http://formvalidation.io/api/

Another point is very important: the Bootstrap of this plug-in is better to use their own, a little changed. You do not need to download the SDK from the Bootstrap website.

Upward effect:



 

Pilot resource import:

<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css" rel="external nofollow" />  <link rel="stylesheet" href="dist/css/formValidation.css" rel="external nofollow" /
<script type="text/javascript" src="vendor/jquery/jquery.min.js"></script>  <script type="text/javascript" src="vendor/bootstrap/js/bootstrap.min.js"></script>  <script type="text/javascript" src="dist/js/formValidation.js"></script>  <script type="text/javascript" src="dist/js/framework/bootstrap.js"></script>  <script type="text/javascript" src="dist/js/language/zh_CN.js"></script>

Html:

<form id="defaultForm" class="form-horizontal">  <div class="form-group">    <label class="col-xs-3 control-label">Full name</label>    <div class="col-xs-5">      <input type="text" class="form-control" name="boxId" />    </div>  </div></form>

The following is the verification code;

$ ('# Ultultform '). formValidation ({message: 'invalid value ', icon: {valid: 'glyphicon glyphicon-OK', invalid: 'glyphicon glyphicon-delete', validating: 'glyphicon glyphicon-refresh'}, locale: 'zh _ cn', fields: {boxId: {verbose: false, // indicates that the verification is performed in order. Verification is successful before the next (verification is successful before the last remote verification is sent) validators: {notEmpty: {message: 'This is a required field'}, digits: {message: 'value is not number'}, stringLength: {min: 16, message: 'must be 16 number'}, remote: {type: 'post', url: '/box/unique', message:' This device number already exists ', delay: 2000 }}, onSuccess: function () {// click Submit Form. All forms are verified successfully }});

Background return

{"Valid": true} // verification passed or {"valid": false} // No-'this device number already exists ',

;




The above section describes how to implement the remote verification function of the Bootstrap Form Verification formValidation introduced by xiaobian. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

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.