1 回答
TA贡献1848条经验 获得超6个赞
您还需要创建客户端验证。您可以使用ClientValidationFunctionValidator 来执行此操作。
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="tbEmail"
ClientValidationFunction="allowedDomains" ErrorMessage="Not Valid"></asp:CustomValidator>
<script type="text/javascript">
function allowedDomains(sender, element) {
var approvedDomains = ['<%= string.Join("', '", approvedEmailDomains) %>'];
element.IsValid = $.inArray(element.Value, approvedDomains) > -1;
}
</script>
为此,您需要一个public列表
public List<string> approvedEmailDomains;
protected void Page_Load(object sender, EventArgs e)
{
approvedEmailDomains = new List<string>()
{
"domainnameihid.com",
"stackoverflow.com"
};
}
- 1 回答
- 0 关注
- 94 浏览
添加回答
举报