---------------------------------------------------
This is the HTML section of Custom Validator Control.
<asp:CustomValidator ID="custVal" runat="Server" ValidationGroup="grpProductAdd"
Display="None" ErrorMessage="Please, Enter Product Amount." ClientValidationFunction="CheckProduct">
</asp:CustomValidator>
We need a javascript function to use Custom Validation that return either 'true' or 'false' result.
<script language="javascript" type="text/javascript">
// You must use this both parameter with your function, because by it Validator validate the result.
function CheckProduct(sender, args)
{
// This is the variable name by which we can identify true/false result.
var Check = 0;
var ProductVal = document.getElementById('txtProductVal').value;
if (ProductVal = '')
{
Check = 0
}
else
{
Check = 1
}
// If your condition become true
if (Check == '0' )
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
</script>
That's It !
Hope you will like it.
0 comments:
Post a Comment