RegularExpressionValidat
aspx页面中RegularExpressionValidat
![RegularExpressionValidat<wbr>or <wbr>忽略大小写 RegularExpressionValidator <wbr>忽略大小写](https://i-blog.csdnimg.cn/blog_migrate/a4c26d1e5885305701be709a3d33442f.gif)
![RegularExpressionValidat<wbr>or <wbr>忽略大小写 RegularExpressionValidator <wbr>忽略大小写](https://i-blog.csdnimg.cn/blog_migrate/a4c26d1e5885305701be709a3d33442f.gif)
<
script type
=
"
text/javascript
"
>
function RegularExpressionValidat orEvaluateIsValid(val) {
var value
=
ValidatorGetValue(val.controltovalidate);
if
(ValidatorTrim(value).length
==
0
)
return
true
;
var rx
=
null
;
if
(val.validationexpression.indexOf(
"
(?i)
"
)
>=
0
) {
rx
=
new
RegExp(val.validationexpression.replace(
"
(?i)
"
,
""
),
"
i
"
);
}
else
{
rx
=
new
RegExp(val.validationexpression);
}
var matches
=
rx.exec(value);
return
(matches
!=
null
&&
value
==
matches[
0
]);
}
</
script
>
这段代码需要放在form的底部,
不要放到了form外面,body的底部。
经过这样的改造,RegularExpressionValidat or的验证就可以忽略大小写了。