tags:

views:

16

answers:

0

Hello!

I have a custom validator that validates input (date, double etc), i have other javascript code that runs on input.change(). If my custom validator fails i dont want the other javascript code to run (because input is invalid).

For instance, i have code like this:

$('input:text[id$=_nbAmount_txtNumber]').change(mainAmountChanged);

mainAmountChanged() will execute on change, but i only want this to run IF _nbAmount_txtNumber validates. This validation is done like this:

<asp:CustomValidator ID="txtNumber_CustomValidator" runat="server" ErrorMessage="Custom Validation Error"
ClientValidationFunction="validate" ControlToValidate="txtNumber" Display="Dynamic">*</asp:CustomValidator>

function validate(sender, args) {

  args.IsValid = true or false;

}

The reason for this is that the validation is done in a user control (number box) since i dont want to do this validation for every new numberbox i add to my website. Then as i have mentioned i have some pages where these numberboxes is used in calculations using javascript, i dont want these calculations to be made if the validation fails.

I hope im clear enough about my problem :)