thinkphp5使用bootstrapvalidator进行异步验证邮…

2018-06-22 00:59:07来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

本文介绍了thinkphp5使用bootstrapvalidator进行异步验证邮箱的示例,分享给大家,具体如下:

js验证

/**
 * Created by HONGXIN on 2017-10-23.
 */
$(function () {
  $('form').bootstrapValidator({

    message: 'This value is not valid',
    feedbackIcons: {
      valid: 'glyphicon glyphicon-ok',
      invalid: 'glyphicon glyphicon-remove',
      validating: 'glyphicon glyphicon-refresh'
    },

    live: 'disabled',//验证失败后,提交按钮仍然是可选状态

    fields: {
      email: {
        message: '用户名验证失败',//默认
        verbose: false,
        validators: {
          notEmpty: {
            message: '邮箱不能为空'
          },
          emailAddress: {
            message: '邮箱地址格式有误'
          },
          remote: {
            url: '/ajax_email',
            message:"此邮箱已经注册",
            type: "post",
            dataType: 'json',
            data: {
              //默认传递的就是输入框的值
            },
            delay: 500,//延迟效果
          },
        }
      },
      password: {
        validators: {
          notEmpty: {
            message: '邮箱地址不能为空'
          },
          stringLength: {
            min: 6,
            max: 18,
            message: '用户名长度必须在6到18位之间'
          },
        },
      },
      password2: {
        validators: {
          notEmpty: {
            message: '确认密码不能为空'
          },
          identical: {
            field: 'password',
            message: '两次密码必须一致'
          }
        }
      },
      username:{
        validators: {
          notEmpty: {
            message: '用户名不能为空'
          },
          stringLength: {
            min: 2,
            max: 8,
            message: '用户名长度必须在2到8位之间'
          }
        }
      }

    }
  });
});

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:实例讲述PHP实现中秋博饼游戏之绘制骰子图案功能

下一篇:实例讲述PHP实现双链表删除与插入节点的方法