本文将分享bootstrapvalidator提供了哪些验证函数的详细内容,并且还将对bootstrap验证模型进行详尽解释,此外,我们还将为大家带来关于"BootstrapValidationSta
本文将分享bootstrap validator 提供了哪些验证函数的详细内容,并且还将对bootstrap验证模型进行详尽解释,此外,我们还将为大家带来关于"Bootstrap Validation States"的中文翻译是"Bootstrap验证状态"、bootstrap bootstrapvalidator插件+adjax验证使用、BootStrap Validator、Bootstrap Validator 表单验证的相关知识,希望对你有所帮助。
本文目录一览:- bootstrap validator 提供了哪些验证函数(bootstrap验证模型)
- "Bootstrap Validation States"的中文翻译是"Bootstrap验证状态"
- bootstrap bootstrapvalidator插件+adjax验证使用
- BootStrap Validator
- Bootstrap Validator 表单验证
bootstrap validator 提供了哪些验证函数(bootstrap验证模型)
总结
以上是小编为你收集整理的bootstrap validator 提供了哪些验证函数全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
"Bootstrap Validation States"的中文翻译是"Bootstrap验证状态"
Bootstrap 包括错误、警告和成功消息的验证样式。要使用,只需将适当的类(.has-warning、.has-error 或 .has-success)添加到父元素即可。
示例
您可以尝试运行以下代码用于实现验证状态
实时演示
<!DOCTYPE html> <html> <head> <title>Bootstrap Example</title> <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet"> <script src = "/scripts/jquery.min.js"></script> <script src = "/bootstrap/js/bootstrap.min.js"></script> </head> <body> <formrole = "form"> <div> <label>Focused</label> <div> <inputid = "focusedInput" type = "text" value = "This is focused..."> </div> </div> <div> <label for = "inputPassword">Disabled</label> <div> <inputid = "disabledInput" type = "text" placeholder = "Disabled input here..." disabled> </div> </div> <fieldset disabled> <div> <label for = "disabledTextInput"> Disabled input (Fieldset disabled) </label> <div> <input type = "text" id = "disabledTextInput"placeholder = "Disabled input"> </div> </div> <div> <label for = "disabledSelect"> Disabled select menu (Fieldset disabled) </label> <div> <select id = "disabledSelect"> <option>Disabled select</option> </select> </div> </div> </fieldset> <div> <labelfor = "inputSuccess"> Input with success </label> <div> <input type = "text"id = "inputSuccess"> </div> </div> <div> <labelfor = "inputWarning"> Input with warning </label> <div> <input type = "text"id = "inputWarning"> </div> </div> <div> <labelfor = "inputError"> Input with error </label> <div> <input type = "text"id = "inputError"> </div> </div> </form> </body> </html>
以上就是"Bootstrap Validation States"的中文翻译是"Bootstrap验证状态"的详细内容,更多请关注php中文网其它相关文章!
bootstrap bootstrapvalidator插件+adjax验证使用
1、利用bootstrap Validator表单验证进行表单验证需要如下CSS和JS.
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrapValidator.css" />
<script src="js/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="js/bootstrap.js" type="text/javascript"></script>
<script src="js/bootstrapValidator.js"></script>
具体样式找bootstrap Validator官网
2、validate规则配置
<script type="text/javascript">
$(function () {
$(''form'').bootstrapValidator({
message: ''This value is not valid'',
feedbackIcons: {
valid: ''glyphicon glyphicon-ok'',
invalid: ''glyphicon glyphicon-remove'',
validating: ''glyphicon glyphicon-refresh''
},
fields: {
account: {
message: ''用户名验证失败'',
validators: {
stringLength: {
min: 3,
max: 15,
message: ''用户名长度必须在3到15位之间''
},
regexp: {
regexp: /^[a-z0-9_-]{3,16}$/,
message: ''用户名只能包含、小写、数字和下划线''
}
}
},
password: {
validators: {
stringLength: {
min: 6,
max: 18,
message: ''密码长度必须在6到18位之间''
},
regexp: {
regexp: /^[a-z0-9_-]{3,16}$/,
message: ''密码只能包含、小写、数字和下划线''
}
}
},
repassword: {
message: ''密码无效'',
validators: {
identical: {//相同
field: ''password'',
message: ''两次密码不一致''
},
}
},
email: {
validators: {
emailAddress: {
message: ''邮箱地址格式有误''
}
}
}
}
});
});
3、对应的html页面如下
<div>
<h3>GET STARTED</h3>
<formrole="form" id="register_form">
<div>
<inputname="account" id="account" type="text"
placeholder="Your Account">
</div>
<div>
<inputname="email" id="email" type="text"
placeholder="Your Email">
</div>
<div>
<inputname="password" id="password" type="password"
placeholder="Password">
</div>
<div>
<inputname="repassword" id="repassword" type="password"
placeholder="Repassword">
</div>
<div>
<input type="button"value="Register"
onclick="register_ajax(''#register_form'')">
</div>
<p>Do have account? Please <a
href="/api/login/">Login</a>.</p>
</form>
</div>
4、ajax 处理表单提交脚本如下:
/*表单信息异步传输*/
function register_ajax(id) {
if ($(id).data(''bootstrapValidator'').isValid()) {
var data = $(id).serializeJSON();
var url;
if (id === "#register_form") {
url = ''/api/register/'';
}
$.ajax({
type: ''post'',
url: url,
data: JSON.stringify(data),
contentType: "application/json",
success: function (data) {
if (data === ''恭喜您,账号已成功注册'') {
window.location.href = ''/api/login/'';
} else {
alert(data);
}
},
error: function () {
alert(''Sorry,服务器可能开小差啦, 请重试!'')
}
});
}
}
其他的一些用法可以参考https://www.cnblogs.com/zhangtongzct/p/5728592.html
BootStrap Validator
表单验证,必须有Form表单,需要用到form-group
如果使用了 input-group 无法显示出 校验提示
<div class="input-group">
<span class="input-group-addon">姓名</span>
<input type="text" id="username" class="form-control" value="${username}" placeholder="姓名">
</div>
引入:
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Content/bootstrap/js/bootstrap.min.js"></script>
<link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<script src="~/Content/bootstrapValidator/js/bootstrapValidator.min.js"></script>
<link href="~/Content/bootstrapValidator/css/bootstrapValidator.min.css" rel="stylesheet" />
<form>
<div>
<label>Username</label>
<input type="text"name="username" />
</div>
<div>
<label>Email address</label>
<input type="text"name="email" />
</div>
<div>
<button type="submit" name="submit">Submit</button>
</div>
</form>
$(function () {
$(''form'').bootstrapValidator({
message: ''This value is not valid'',
feedbackIcons: {
valid: ''glyphicon glyphicon-ok'',
invalid: ''glyphicon glyphicon-remove'',
validating: ''glyphicon glyphicon-refresh''
},
fields: {
username: {
message: ''用户名验证失败'',
validators: {
notEmpty: {
message: ''用户名不能为空''
}
}
},
email: {
validators: {
notEmpty: {
message: ''邮箱地址不能为空''
}
}
}
}
});
});
Bootstrap Validator 表单验证
在线演示地址:
使用方法,代码如下所示:
今天关于bootstrap validator 提供了哪些验证函数和bootstrap验证模型的介绍到此结束,谢谢您的阅读,有关"Bootstrap Validation States"的中文翻译是"Bootstrap验证状态"、bootstrap bootstrapvalidator插件+adjax验证使用、BootStrap Validator、Bootstrap Validator 表单验证等更多相关知识的信息可以在本站进行查询。
本文标签: