<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<input type="file" lang="de" />
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="FileUpload1"
ErrorMessage="CustomValidator" ClientValidationFunction="clientValidate"></asp:CustomValidator></div>
</form>
<script type="text/javascript">
function clientValidate(source,arguments){
var rgx=/(jpg|gif|bmp)/i;
var sFilePath=document.getElementById("<%=FileUpload1.ClientID %>").value;
var ext=sFilePath.substring(sFilePath.lastIndexOf(".")+1);
arguments.IsValid=rgx.test(ext);
}
</script>
</body>
</html>