jQuery验证远程错误消息 [英] jQuery Validate Remote Error Message

查看:72
本文介绍了jQuery验证远程错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery验证插件( http://jqueryvalidation.org/ )进行表单验证。有一个字段我想做远程验证。

I am using jquery validation plugin (http://jqueryvalidation.org/) for form validation. There is a field I want to do remote validate.

示例代码:

$( "#myform" ).validate({
    rules: {
        email: {
            required: true,
            email: true,
            remote: "check-email.php"
        }
    }
});

如果无效,则显示请修复此字段。如何为远程验证设置自定义错误消息,例如已使用的电子邮件地址。请使用其他电子邮件。?

When it is not valid, it display "Please fix this field." How can I have custom error message for the remote validate such as "Email address already in used. Please use other email."?

谢谢。

推荐答案

他们的文档似乎显示消息选项。这有用吗?

their documentation seems to show a message option. can that be helpful ?

http://jqueryvalidation.org/validate

他们网站上的示例:

$(".selector").validate({
  rules: {
    name: "required",
    email: {
      required: true,
      email: true
    }
  },
  messages: {
    name: "Please specify your name",
    email: {
      required: "We need your email address to contact you",
      email: "Your email address must be in the format of name@domain.com"
    }
  }
});

这篇关于jQuery验证远程错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆