Bootstrap Validator 表单验证_javascript技巧

在线演示地址:http://www.shouce.ren/study/api/s/jq--BootstrapValidator--index.html

使用方法,代码如下所示:

1.<form id="defaultForm" method="post" class="form-horizontal" action="target.php">
2. <div class="form-group">
3. <label class="col-lg-3 control-label">用户名</label>
4. <div class="col-lg-5">
5. <input type="text" class="form-control" name="username" />
6. </div>
7. </div>
8.
9. <div class="form-group">
10. <label class="col-lg-3 control-label">邮箱</label>
11. <div class="col-lg-5">
12. <input type="text" class="form-control" name="email" />
13. </div>
14. </div>
15.
16. <div class="form-group">
17. <label class="col-lg-3 control-label">生日</label>
18. <div class="col-lg-5">
19. <input type="text" class="form-control" name="birthday" /> (YYYY/MM/DD)
20. </div>
21. </div>
22.
23. <div class="form-group">
24. <div class="col-lg-9 col-lg-offset-3">
25. <button type="submit" class="btn btn-primary" name="signup" value="Sign up">提交</button>
26. <button type="button" class="btn btn-info" id="validateBtn">自动验证</button>
27. <button type="button" class="btn btn-info" id="resetBtn">重置表单</button>
28. </div>
29. </div>
30.</form>
1.$('#defaultForm').bootstrapValidator({
2. message: 'This value is not valid',
3. feedbackIcons: {
4. valid: 'glyphicon glyphicon-ok',
5. invalid: 'glyphicon glyphicon-remove',
6. validating: 'glyphicon glyphicon-refresh'
7. },
8. fields: {
9. username: {
10. message: 'The username is not valid',
11. validators: {
12. notEmpty: {
13. message: 'The username is required and cannot be empty'
14. },
15. stringLength: {
16. min: 6,
17. max: 30,
18. message: 'The username must be more than 6 and less than 30 characters long'
19. },
20. regexp: {
21. regexp: /^[a-zA-Z0-9_\.]+$/,
22. message: 'The username can only consist of alphabetical, number, dot and underscore'
23. },
24. remote: {
25. url: 'remote.php',
26. message: 'The username is not available'
27. },
28. different: {
29. field: 'password',
30. message: 'The username and password cannot be the same as each other'
31. }
32. }
33. },
34. email: {
35. validators: {
36. emailAddress: {
37. message: 'The input is not a valid email address'
38. }
39. }
40. },
41. }
42.});

以上所述是小编给大家介绍的Bootstrap Validator 表单验证的全部叙述,希望对大家有所帮助,如果大家想了解更多内容敬请关注!

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索bootstrap表单验证
validator表单验证
bootstrapvalidator、bootstrap validator、bootstrap3 validator、bootstrapvalidator3、bootstrap的validator,以便于您获取更多的相关知识。

时间: 2024-09-02 19:54:18

Bootstrap Validator 表单验证_javascript技巧的相关文章

js浏览器html5表单验证_javascript技巧

html5表单添加了很多类型的表单,而且还自带验证的功能.在移动端,手机等设备能够根据不同的input类型弹出不同的键盘,例如iphone弹的键盘 但是由于不同的浏览器对不合法输入提示文案不一致,样式也不一样,并且老的浏览器不兼容(IE9及以下),导致了在生产环境中比较少见到.例如对于邮箱格式的检验,不同浏览器的效果如下: Chrome Firefox IE safari html5的表单跨浏览器有很大的问题 具体来说存在三个问题: (1) 输入框blur的时候不会触发检查,只有在点提交时才触发

轻松搞定js表单验证_javascript技巧

先看看效果图: html: 引入 <script src="/Scripts/jquery-1.10.2.js"></script> <script src="/Scripts/Validate-1.0.1.js"></script> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head ru

javascript html5实现表单验证_javascript技巧

表单验证为终端用户检测无效的数据并标记这些错误,是一种用户体验的优化. 下面展现浏览器自带的验证功能也可在移动端中查看: HTML部分: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-sc

分享纯手写漂亮的表单验证_javascript技巧

哈哈 手工馒头好吃,今天小编跟大家分享手工js表单验证代码,感兴趣的朋友快来吧. 因为是自定义样式,所以兼容所有浏览器版本,个人认为非常漂亮:网址wuxi.rongzi.com css <style> /*tooltip*//* CSS属性顺序按照 字母首字母 排列*/ .ui-slider-tooltip{ background:#fa; border:px solid #fa; color:#fff; display: block; text-align: left; padding: p

javascript制作的简单注册模块表单验证_javascript技巧

一个注册框  进行表单验证处理 如图 有简单的验证提示功能 代码思路也比较简单 输入框失去焦点时便检测,并进行处理 表单具有 onsubmit = "return check()"行为,处理验证情况 点击提交表单按钮时,进行最终的验证,达到是否通过表单提交的请求. 先是最基本的html+css部分 <style type="text/css"> body{margin:0;padding: 0;} .login{position:relative;mar

JavaScript实现仿网易通行证表单验证_javascript技巧

介绍一下表单验证,不错哦: 如图 CSS代码 @charset "gb2312"; /* CSS Document */ body,dl,dt,dd,div,form {padding:0;margin:0;} #header,#main{ width:650px; margin:0 auto; } .bg{ background-image:url(../images/register_bg.gif); background-repeat:no-repeat; width:6px;

javascript实现的简单的表单验证_javascript技巧

表单验证几乎是不可缺少的,有的表单验证是在后台完成的,有的则是使用JavaScript在在前端完成基本的验证,这样可以有效的减轻服务器的压力,下面就介绍一下JS实现的最简单的表单验证.代码实例如下: <!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <title></title> <script type="text/javascript&q

javascript实现表单验证_javascript技巧

本文实例讲解了javascript实现表单验证的详细代码,分享给大家供大家参考,具体内容如下 效果图: 具体代码: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <script type="text/j

Bootstrap表单布局_javascript技巧

Bootstrap 提供了下列类型的表单布局: •垂直表单(默认) -> 这个不好看,都是手机版了,PC版占一排不好看: •内联表单 -> 我相信这个才是你想要的,PC版响应横排,手机版响应竖排. •水平表单 -> 用栅格系统控制显示 一.垂直表单 垂直表单使用的标准步骤 1.<form> 元素添加 role="form". 2.把标签和控件放在一个带有"form-group"的<div> 中,获取最佳间距. 3.向所有的文