Community discussion forum

Async Validation with Custom validator and Ajax validator callout

  • 1 year ago
    Hi Peeps, I have broken my brain on this problem for 2 days now and have had to admit defeat, i can't get this to work. Basically, what i want to achieve is custom validation of fields which uses server side code to do it, and have the result of the validation be displayed in a validator callout should it be invalid. I can write the custom validator ok, i can write the server side code and populate a temporary array to hold the validation results. the server side call back works fine too. However, no matter what value i pass back, the validator just accepts it like it was an accept. Can anyone tell me if the act of using a page method with ajax interferes with validators? Cheers Si
  • 1 year ago
    hey Simon, Sounds like a fun one. Just to clarify first... your validation works fine with a non-AJAX form submit, but when you try and do an AJAX-submit (are you using the UpdatePanel?) then the validation doesn't get triggered? James
  • 1 year ago
    Hi James, It is really weird this one. The custom validator event fires ok, i check my array to make sure that the call hasn't already been made to validate the value in the text box. if it hasn't, i use the page method to call the server side and do the validation. the validation function then sets IsValid to false to stop the form being submitted while the validation occurs. Once the async call has finished, it calls a succeeded function in javascript, which populates the array, and then forces validation of the custom validator again to pick up the results. Here is what happens, if i miss out the async call and just leave it as IsValid = false; then the validatorcallout works. If i leave it in, then no matter the result in the array, the validator will not show. setting IsValid to true or false has no effect, it seems from stepping through the code, that the ajax toolkit is deeming the callout invalid and therefore should be hidden. The other strange behaviour i see, is that the event fires continuously when i give focus back to the textbox. It has baffled me. i really needed it to work to get a nice consistent feel to the web front end, without needing to replicate all the logic in javascript (especially as some requires custom regex's and processes that i don't want to give away). There is no updatepanel involved either, i am just plain baffled :O( Any ideas? Si

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback