zoukankan      html  css  js  c++  java
  • jQuery表单验证

    登录验证:
    $(function(){
    $("#文本框id").focus(function(){ // 输入账号的文本框获得鼠标焦点
    var name = $(this).val(); // 得到当前文本框的值
    if(name=="请输入6~12位账号"){
    $(this).val(""); // 如果符合条件,则清空文本框内容
    }
    });
    $("#文本框id").blur(function(){// 文本框失去鼠标焦点
    var name = $(this).val(); // 得到当前文本框的值
    if(name==""){
    $(this).val("请输入6~12位账号");// 如果符合条件,则设置内容
    }
    });
    });
    表单验证:
    $(function(){
    $("#txtNo").blur(function(){
    var name=$(this).val();
    if(name==""||name==null)
    {
    $("#prompt_no").html("用户账号不能为空!");
    return false;
    }
    if(name.length<6||name.length>12)
    {
    $("#prompt_no").html("账号的长度在6到12位之间!");
    return false;
    }
    $("#prompt_no").html("<img src='images/ok.gif'/>");
    });
    $("#txtPwd").blur(function(){
    var pwd=$(this).val()
    if(pwd==""||pwd==null)
    {
    $("#prompt_pwd").html("密码不能为空!");
    return false;
    }
    if(pwd.length<6||pwd.length>12)
    {
    $("#prompt_pwd").html("密码的长度在6到12位之间");
    return false;
    }
    $("#prompt_pwd").html("<img src='images/ok.gif'/>");
    });
    $("#txtConfirmPwd").blur(function(){
    var pwds=$(this).val();
    if(pwds==""||pwds==null){
    $("#prompt_confirmpwd").html("密码不能为空!");
    return false;
    }
    if(pwds!=$("#txtPwd").val())
    {
    $("#prompt_confirmpwd").html("两次输入的密码要一致!");
    return false;
    }
    $("#prompt_confirmpwd").html("<img src='images/ok.gif'/>");
    });

    $("#txtName").blur(function(){
    var names=$(this).val();
    if(names==""||names==null){
    $("#prompt_name").html("用户名不能为空!");
    return false;
    }
    if(names.length<6||names.length>12)
    {
    $("#prompt_name").html("用户名的长度在6到12位之间!");
    return false;
    }
    $("#prompt_name").html("<img src='images/ok.gif'/>");

    });
    $("#txtId").blur(function(){
    var idReg=/^d{15}$|^d{18}$/;
    var id=$(this).val();
    if(id==""||id==null)
    {
    $("#prompt_id").html("身份证不能为空!");
    return false;
    }
    if(!idReg.test(id))
    {
    $("#prompt_id").html("身份证格式不正确!");
    return false;
    }
    $("#prompt_no").html("<img src='images/ok.gif'/>");
    });

    $("#txtPhone").blur(function(){
    var phoneReg=/^(13|15|18)d{9}$/;
    var phone=$(this).val();
    if(phone==""||phone==null)
    {
    $("#prompt_phone").html("手机号不能为空!");
    return false;
    }
    if(!phoneReg.test(phone))
    {
    $("#prompt_phone").html("手机号格式不正确!");
    return false;
    }
    $("#prompt_phone").html("<img src='images/ok.gif'/>");
    });

  • 相关阅读:
    Format中的转换说明符
    网络通信数据包与串口通信数据包异同:
    指针容器的类型和用法
    cimge 这次能够图片大小尺寸
    三分钟快速上手TensorFlow 2.0 (后续)——扩展和附录
    三分钟快速上手TensorFlow 2.0 (下)——模型的部署 、大规模训练、加速
    三分钟快速上手TensorFlow 2.0 (中)——常用模块和模型的部署
    三分钟快速上手TensorFlow 2.0 (上)——前置基础、模型建立与可视化
    检查自己的numpy是否有依赖blas
    TensorFlow 2.0快速上手指南12条
  • 原文地址:https://www.cnblogs.com/you-zi/p/4351200.html
Copyright © 2011-2022 走看看