bootstrapValidator. min. js form validation plug in
- 2021-07-18 06:52:34
- OfStack
In this article, we share the specific code of bootstrapValidator. min. js form verification for your reference. The specific contents are as follows
Note: After downloading, select all copies and paste them into the new js file named bootstrapValidator. min. js.
Test code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
table{
width: 690px;
}
th{
padding-left: 23%;
padding-bottom: 20px;
}
td{
width: 110px;
}
b{
color: #f00;
}
</style>
</head>
<body>
<!-- Form -->
<div class="ctn">
<form class="fm" method="post" onsubmit="return doTable()">
<table align="center">
<th class="perWl" align="left" colspan="2"> Logistics service provider </th>
<tr>
<td class="txt" align="right" width="100"> Deng Land Name Said: </td>
<td class="wlIcon icon">
<s></s>
<input type="text" name="lgname" maxlength="20"/>
<b>*</b>
<span></span>
</td>
</tr>
<tr>
<td class="txt" align="right"> Dense Code: </td>
<td class="wlIcon icon">
<s class="mm"></s>
<input type="password" name="password" maxlength="18"/>
<b>*</b>
<span></span>
</td>
</tr>
<tr>
<td class="txt" align="right"> Indeed Recognize Dense Code: </td>
<td class="wlIcon icon">
<s class="mm"></s>
<input type="password" name="repass" maxlength="18"/>
<b>*</b>
<span></span>
</td>
</tr>
<tr>
<td class="wlBtns" align="center" colspan="2">
<s></s>
<button type="submit"> Note Volume </button>
<button class="cancel" type="submit"> Take Elimination </button>
</td>
</tr>
</table>
</form>
</div>
<script src="js/jquery-1.11.3.js"></script>
<script src="js/bootstrapValidator.min.js"></script>
<script type="text/javascript">
/* Form validation */
var gets = true;// Do you want the form to be submitted
$(function(){
// Prompt information ===========================================
$("input[name=lgname]").focus(function(){
if($(this).val() == this.defaultValue){
$(this).val('');
}
}).blur(function(){
if($(this).val() == ''){
$(this).val(this.defaultValue);
}
});
// The method to be executed when the input box loses focus
$("input[name=lgname]").blur(function(){doLgname();});
$("input[name=password]").blur(function(){doPassword();});
$("input[name=repass]").blur(function(){doRepass();});
});
// Verification of login name ==========================
function doLgname(){
var t = $("input[name=lgname]");
var span = t.next();
if(/^\w{6,16}$/.test(t.val())){
span.html(" Fill in correctly ").css({color:"green",fontSize:"12px"});
return true;
}else{
span.html(" Contains numbers, letters, underscores, and lengths in the 6-16 Between ").css({color:"#ec4e4e",fontSize:"12px"});
return false;
}
}
// Verification of passwords ==========================
function doPassword(){
var t = $("input[name=password]");
var span = t.next();
if(t.val() == ''){
span.html(" Password cannot be empty ").css({color:"#ec4e4e",fontSize:"12px"});
return false;
}else{
span.html('');
if(/.{15,}/.test(t.val())){
span.html(" Illegal password length ");
return false;
}
return true;
}
}
// Verify password verification ==========================
function doRepass(){
var t = $("input[name=repass]");
var span = t.next();
if(t.val() == $("input[name=password]").val() && t.val() != ''){
span.html(" Fill in correctly ").css({color:"green",fontSize:"12px"});
return true;
}else{
span.html(" Twice password no 1 To ").css({color:"#ec4e4e",fontSize:"12px"});
return false;
}
}
// Methods executed when data is submitted
function doTable(){
var lg = doLgname();
var pass = doPassword();
var repass = doRepass();
if(lg&&pass&&repass){
return true;
}else{
return false;
}
}
</script>
</body>
</html>
Form plug-in: bootstrapValidator. min. js download address