Custom control not validating

31-Mar-2019 04:35

I had already found out that the standard approach (args.value) doesn't work because the value isn't sent to the function from these controls.I found the following example on a forum somewhere but it only works when the script is in the ascx file. I tried your code just as it was (but with the Data Binder set to one of my DB columns) but got the same error as I had when I had previously tried this myself.The validator is going to make sure that a credit card number has 16 digits and that it comes from an accepted credit card company.In order to perform such validation, we have to implement a validator function that has the following signature: That’s the method signature used for both template-driven and reactive forms.Before we can learn “how to do custom validation”, we must dive into the workings of the APIs first to see what’s happening and actually have some idea what’s going on, so let’s do that real quick.

If you enjoyed this article, please clap for it or share it.

You meant put the JS in the ASPX file not the ASCX right?

I've just tried it out and it works fine, so thank you very much.

The Java Script validation function is not recognised when it is in the ASCX file.

The error I get is: "Microsoft JScript runtime error: 'client Unit Price Validation' is undefined".

If you enjoyed this article, please clap for it or share it. You meant put the JS in the ASPX file not the ASCX right?I've just tried it out and it works fine, so thank you very much.The Java Script validation function is not recognised when it is in the ASCX file.The error I get is: "Microsoft JScript runtime error: 'client Unit Price Validation' is undefined".For anybody else copying this, please not that the snippet Princy supplied needs a small modification.