У меня есть поле, которое не требуется, но я все еще хочу добавить к нему регулярное выражение.
$.validator.addMethod(
"regex",
function (value, element, regexp) {
var check = false;
var re = new RegExp(regexp);
return this.optional(element) || re.test(value);
},
"Please check your input."
);
$(".numeric").rules("add", { number: true });
});
@Html.TextBoxFor(model => model.PurchaseAmount, new { @class = "currency numeric", Value = String.Format("{0:0.00}", Model.PurchaseAmount), style = "width:160px" })
Поскольку поле не требуется, оно не будет работать.Есть идеи, которые могли бы помочь?