Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
a-z正则表达式在jQuery验证中不起作用_Jquery_Regex - Fatal编程技术网

a-z正则表达式在jQuery验证中不起作用

a-z正则表达式在jQuery验证中不起作用,jquery,regex,Jquery,Regex,我的代码看起来像这样。帮帮我 $('#form').validate({ errorElement: "span", // contain the error msg in a span tag errorClass: 'help-block', ignore: "", rules: { CountryName: { required: true, regex: /^[a-zA-Z]+$/ } }, messages: {

我的代码看起来像这样。帮帮我

$('#form').validate({
  errorElement: "span", // contain the error msg in a span tag
  errorClass: 'help-block',
  ignore: "",
  rules: {
    CountryName: {
      required: true,
      regex: /^[a-zA-Z]+$/
    }
  },
  messages: {
    CountryName: {
      required: "Enter Country name",
      regex: "Enter Correct Country name",
    },
  },

没有
regex
规则,它被称为
pattern
,来自
附加方法
文件

jQuery(函数($){
$(“#表单”)。验证({
errorElement:“span”,//在span标记中包含错误消息
errorClass:“帮助阻止”,
忽略:“,
规则:{
国家名称:{
要求:正确,
模式:/^[a-zA-Z]+$/
}
},
信息:{
国家名称:{
必填项:“输入国家名称”,
模式:“输入正确的国家名称”,
}
}
});
});


这与ASP.Net MVC无关。编辑相应。谢谢你的帮助。它对我有用。但它默认显示消息“无效格式”instade off my msg“输入正确的国家名称”。请告诉我需要做哪些更改?@SiddharthVarlekar,因为在消息中仍然使用了
regex