I am practising client side validations with server side. I have written a code in client side to validate name and it is returing the value. But problem is that for incorrect values the error message is not displaying as soon as focus lost from the text box. My implementation is as:
Updated
<script type="text/javascript">
function validateText(osrc, args) {
var textvalue = args;
var pattern = /^[a-zA-Z.]{3,25}$/
if (textvalue != null || textvalue != "") {
if (pattern.test(textvalue)) {
args.isValid = true;
}
else
args.isValid = false;
}
else args.isValid = false;
return;
}
</script>
and aspx page contents are
<asp:TextBox runat="server" ID="txtFirstName" CssClass="form-control" />
<asp:CustomValidator runat="server" Display="Dynamic" CssClass="text-danger"
ControlToValidate="txtFirstName" ToolTip="Incorrect Text" ErrorMessage="*"
EnableViewState="false" ValidateEmptyText="true" EnableClientScript="true"
Enabled="true" ClientValidationFunction="validateText"></asp:CustomValidator>//This validator is not showing the error message
What's wrong with it, help required.