$(document).ready(function() {
    //聚焦第一个输入框
    $("#invtype").focus();                          //form 第一个文本框
    //为inputForm注册validate函数
    $("#appInvoiceInputForm").validate({
        onsubmit:true,
        errorElement :"div",
        errorPlacement: function(error, element) {
            error.appendTo(element.parent());
        },
        rules: {
            invdateStr:{
                required:true,
                onlyDate:true,
                isDateBefore:true
            },
            buytaxno: {
                required:true,
                isNumOrLetter:true,
                sbhLength:true
            },
            selltaxno:{                
                required:true,
                isNumOrLetter:true,                
                sbhLength:true
            },
            invkind:{
                required:true,
                number:true,
                minlength:[10],
                maxlength:[10],
                isInvkindMatchType:"#invtype"
            },
            invnum:{
                required:true,
                number:true,
                minlength:[8],
                maxlength:[8]
            },
            invcost:{
                required:true,
                onlyMoney:true,
                notZero:true,
                maxlength:[14]
            },
            invvat:{
                required:true,
                onlyMoney:true,
                maxlength:[14]
            },
            invtaxno:{
                required:true,
                isNumOrLetter:true,
                onlyDksbh:true,
                dksbhLength:true                
            },
            vatModel_mw1:{
                onlyMw:true,
                minlength:[21],
                maxlength:[21]
            },
            vatModel_mw2:{
                onlyMw:true,
                minlength:[21],
                maxlength:[21]
            },
            vatModel_mw3:{
                onlyMw:true,
                minlength:[21],
                maxlength:[21]
            },
            vatModel_mw4:{
                onlyMw:true,
                minlength:[21],
                maxlength:[21]
            },
            vatModel_nmw1:{
                onlyMw:true,
                minlength:[27],
                maxlength:[27]
            },
            vatModel_nmw2:{
                onlyMw:true,
                minlength:[27],
                maxlength:[27]
            },
            vatModel_nmw3:{
                onlyMw:true,
                minlength:[27],
                maxlength:[27]
            },
            vatModel_nmw4:{
                onlyMw:true,
                minlength:[27],
                maxlength:[27]
            },
            vatModel_cmw1:{
                onlyMw:true,
                minlength:[28],
                maxlength:[28]
            },
            vatModel_cmw2:{
                onlyMw:true,
                minlength:[28],
                maxlength:[28]
            },
            vatModel_cmw3:{
                onlyMw:true,
                minlength:[28],
                maxlength:[28]
            },
            vatModel_cmw4:{
                onlyMw:true,
                minlength:[28],
                maxlength:[28]
            },
            vendorid:{
                number:true
            }
        },
        messages: {
            invdate:{
                required: " 请输开票日期! "
            },
            buytaxno: {
                required: " 请输入购方纳税人识别号! "
            },            
            selltaxno: {
                required: " 请输入销方纳税人识别号! "                
            },
            invkind:{
                required:" 请输入发票代码! ",
                number:" 只能输入0-9间的数字! ",
                minlength:"发票代码长度应为10位",                                    //需要在页面  添加 maxlength="10";
                maxlength:"发票代码长度应为10位"
            },
            invnum:{                
                required:" 请输入发票号码! ",
                number:" 只能输入0-9间的数字! ",
                minlength:"发票号码长度应为8位",
                maxlength:"发票号码长度应为8位"
            },
            invcost:{
                required:" 请输入金额! "
            },
            invvat:{
                required:" 请输入税额! "
            }
        },
        submitHandler: function(form) {
            $("#loadingdiv").show();
            disableButton();
            form.submit();
        }

});
});

js 表单不为空,数字长度验证的更多相关文章

  1. JS判断提交表单不能为空 等的验证

    转自:https://blog.csdn.net/qiu512300471/article/details/23259811 <script type="text/javascript ...

  2. js表单提交,判断文本框,用户名密码是否为空,JS表单检测!

    当表单提交时先触发验证的js代码,当验证表单的方法返回true时才会提交表单返回false则不提交数据<script type="text/javascript">fu ...

  3. JS表单验证-12个常用的JS表单验证

    JS表单验证-12个常用的JS表单验证 最近有个项目用到了表单验证,小编在项目完结后的这段时间把常用的JS表单验证demo整理了一下,和大家一起分享~~~ 1. 长度限制 <p>1. 长度 ...

  4. js 表单验证控制代码大全

    js表单验证控制代码大全 关键字:js验证表单大全,用JS控制表单提交 ,javascript提交表单:目录:1:js 字符串长度限制.判断字符长度 .js限制输入.限制不能输入.textarea 长 ...

  5. jquery.validation.js 表单验证

    jquery.validation.js 表单验证   官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuer ...

  6. Jquery.validate.js表单验证插件的使用

    作为一个网站web开发人员,以前居然不知道还有表单验证这样好呀的插件,还在一行行写表单验证,真是后悔没能早点知道他们的存在. 最近公司不忙,自己学习一些东西的时候,发现了validation的一个实例 ...

  7. JS表单验证类HTML代码实例

    以前用的比较多的一个JS表单验证类,对于个人来说已经够用了,有兴趣的可以在此基础上扩展成ajax版本.本表单验证类囊括了密码验证.英文4~10个 字符验证. 中文非空验证.大于10小于100的数字.浮 ...

  8. js表单验证工具包

    常用的js表单验证方法大全 /* 非空校验 : isNull() 是否是数字: isNumber(field) trim函数: trim() lTrim() rTrim() 校验字符串是否为空: ch ...

  9. angular js 表单验证

    <!doctype html> <html ng-app="myapp"> <head> <meta charset="UTF- ...

随机推荐

  1. lc面试准备:Implement Stack using Queues

    1 题目 Implement the following operations of a stack using queues. push(x) -- Push element x onto stac ...

  2. 在ASP.NET MVC中对手机号码的验证

    在ASP.NET MVC中,可以使用RegularExpression特性来验证手机号码. public class Customer { [Required(ErrorMessage = " ...

  3. 【转】 std list/vector sort 排序

    [转自]http://blog.csdn.net/marising/article/details/4567531 网上江湖郎中和蒙古大夫很多,因此,此类帖子也很多.关于排序,我还真没研究过,看了江湖 ...

  4. Front-End Engineer 技术栈

    自己根据各种招聘网站上的技术要求做的,希望自己能成为这样的人.

  5. XML文档部署到Tomcat服务器上总是加载出错

    config.xnl 起初文档路径是在src/Dao/config.xml 在Dao目录下BaseDao类中,解析config.xml文件路径 path="/Dao/config.xml&q ...

  6. 干货!如何正确使用Git Flow

    我们已经从SVN 切换到Git很多年了,现在几乎所有的项目都在使用Github管理, 本篇文章讲一下为什么使用Git, 以及如何在团队中正确使用. Git的优点 Git的优点很多,但是这里只列出我认为 ...

  7. mysql登录时,ERROR 1045 (28000): 错误解决办法

    错误问题的描述: ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) ERROR 10 ...

  8. Please check if the Publishing Tools on the server (System/PublishingTools) are started.

    ArcMap或ArcCatalog中双击连接到Server即可,该工具即自动可启动

  9. Docker官方文档翻译之入门

    转自:http://www.cnblogs.com/vikings-blog/p/3958091.html Docker学习总结之docker入门 Understanding Docker 以下均翻译 ...

  10. 平时Error记录

    The Windows Firewall on this machine is currently 1.This row already belongs to another table. DataT ...