Check if this helps:
JS:
<script type="text/javascript" language="javascript">
function validate(sender,args) {
args.IsValid = false;
var tb = document.getElementById('txtInput');
if (args.Value.match(/^\w{6}\d{6}$/)) {
args.IsValid = true
tb.style.backgroundColor = "white";
tb.style.color="green";
}
else {
tb.style.backgroundColor = "red";
}
}
</script>
Markup:
<asp:TextBox ID="txtInput" runat="server"></asp:TextBox>
<asp:Button ID="btnSubmit" runat="server" Text="Button" />
<asp:CustomValidator ID="CustomValidator1"
ControlToValidate="txtInput"
runat="server" ErrorMessage="*"
ClientValidationFunction="validate">
</asp:CustomValidator>
Reputation Points: 12
Solved Threads: 8
Junior Poster in Training
Offline 68 posts
since Jul 2008