189 8069 5689

表单验证提示插件validate

此表单验证插件会对表单字段进行验证,实时提示用户输入信息,用户体验非常好,验证提示紧随input框!

成都创新互联公司专注于盖州网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供盖州营销型网站建设,盖州网站制作、盖州网页设计、盖州网站官网定制、微信小程序开发服务,打造盖州网络公司原创品牌,更为您提供盖州网站排名全网营销落地服务。

以下为表单验证案例代码:


    //引入的插件

    $(document).ready(function(){
        formValidate();                               //表单验证函数
    });
    function formValidate(){
        $("#sendmail").validate({                      //#sendmail表单id
            errorElement : "span",                     //错误信息将放入此标签内
            errorClass: "error_input" ,                //验证出错时使用的css class
            success: "valid" ,                         //自定义验证成功时的动作
            errorPlacement: function(error, element) { //自定义错误消息的显示位置

                element.next().html(error);     //error错误信息,element错误产生的input
            },
                rules: {
                    "from":{
                        required: true
                    },
                    "fromName":{
                        required: true
                    },
                    "to":{
                        required: true
                    },
                    "url":{
                        required: true
                    },
                    "subject":{
                        required: true
                    },
                    "html":{
                        required:true
                    },
                    "contry":{
                        required:true
                    }
                },
            messages: {
                "from":{
                    required: '请输入公司名称'
                },
                "fromName":{
                    required: '请选择省份'
                },
                "to":{
                    required: '请选择城市'
                },
                "url":{
                    required: '请选择县/区'
                },
                "subject":{
                    required: '请输入地址'
                },
                "html":{
                    required:'请选择国家区号'
                },
                "contry":{
                    required:'请选择国家区号'
                }
            },
            submitHandler: function(form){ //表单提交句柄,为一回调函数,带一个参数:form

                form.submit();    //提交表单
            }
        });

    };



    .error_input{color:red;}                         //错误提示的样式


    

发件邮箱:

    

发件姓名:

    

收件邮箱:

    

url:

    

发件主题:

    

选择类别:             中国             美国             日本             俄罗斯             法国             德国                  

    

邮件内容:

    

附  件:


当前题目:表单验证提示插件validate
网站URL:http://jkwzsj.com/article/gscjic.html

其他资讯