我有jquery函数作为validationtype,工作正常
<script type="text/javascript">
jQuery.validator.addMethod("mytest", function (value, element, param) {
var emailPattern = /^[0-9]+$/;
return emailPattern.test(value);
});
jQuery.validator.unobtrusive.adapters.addBool("mytest");
但我的需要是我需要在运行时将正则表达式传递给此函数
如何实现这一点,我试着......
ValidationType = "mytest";
ValidationParameters.Add(“newregex”,strrew);
它反映在html中......
input class =“text-box single-line”data-val =“true”data-val-mytest =“ContactPersonName字段是必需的。”数据-VAL-mytest的-newregex = “/ ^ [A-ZA-Z0-9] {50100} $ /” id =“Desc”name =“Desc”type =“text”value =“”