我正在尝试使用验证两个字段,LiveValidation
但我似乎在任何地方都找不到任何东西。
我正在尝试将Email
andMobile
字段中的一个或另一个设为必填,以便在填写其中一个时不需要填写另一个,但两者都可以输入。
这是我的代码:
<script type="text/javascript">
var Email = new LiveValidation("Email", {validMessage: "", onlyOnBlur: true});
Email.add(Validate.Presence, {failureMessage:"This field is required"});
Email.add(Validate.Format, {pattern: /^[ ]*([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})[ ]*$/i, failureMessage: "A valid email address is required"});
var mobile = new LiveValidation("mobile", {validMessage: "", onlyOnBlur: true});mobile.add(Validate.Presence, {failureMessage:"This field is required"});
var discussion = new LiveValidation("discussion", {validMessage: "", onlyOnBlur: true});discussion.add(Validate.Presence, {failureMessage:"This field is required"});
</script>