RegularExpressionValidator Example

Sashys
Posted by Sashys under ASP.NET category on | Points: 40 | Views : 2726
<script runat="server">
sub Update(sender As Object, e As EventArgs)
if Page.IsValid then
lblText.Text="Page is valid!"
else
lblText.Text="page is not valid!"
end if
end sub
</script>

<html>
<body>

<form runat="server">
Enter US zip code Please:
<asp:TextBox id="txtZipcode" runat="server" />
<asp:Button text="Process" OnClick="Update" runat="server" />
<asp:Label id="lblText" runat="server" />
<br />
<asp:RegularExpressionValidator
ControlToValidate="txtZipcode"
ValidationExpression="\d{5}"
EnableClientScript="false"
ErrorMessage="Zip code should be 5 digit numeric"
runat="server" />
</form>

</body>
</html>

Comments or Responses

Posted by: T.saravanan on: 5/6/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi,
Kindly post your code inside the code tag.

Login to post response