Thanks for your reply. This is what I have.
function validateName(button) { txtName.rules('add', { remote: { url: 'validate.ashx' , data: ({id: txtName.attr('name')}) } } , messages: { remote: '* Error' } }); var canSubmit = 0; var ajaxCalled = false; $().ajaxStart(function() { ajaxCalled = true; }); $().ajaxStop(function() { canSubmit = txtName.valid(); if (canSubmit == 1) { // If the remote validation has completed and returns 'true', execute the ASP.NET server-side onClick event of the button __doPostBack(button.id.replace(/_/g,"$"), ''); } }); var isNameValid = txtName.valid(); return !ajaxCalled && isNameValid == 1; } Essentially the method to returns false anytime the remote validation is fired. This is so that my Save button (ASP.NET Link button) does not execute its server-side onClick event prior to the completion of the jQuery's remote validation. On May 7, 1:34 am, Jörn Zaefferer <joern.zaeffe...@googlemail.com> wrote: > Not easy to solve - you could use $().ajaxStop() to wait for the > request to finish, then you valid() again, this time it will validate > the cached value and return the correct result. > > Jörn > > On Wed, May 6, 2009 at 8:00 AM, Mekilioz <mekil...@gmail.com> wrote: > > > I'm trying to do a jqueryremotevalidationon a 'Name' text field. > > Thevalidationchecks if the name is unique, hence it has to be done > > through theremotemethod. > > > 'Save' button onclick is attached to this javascript method > > > function validateName() { > > txtName.rules('add', { > > remote: { > > url: 'validate.ashx' > > , data: ({id: txtName.attr('name')}) > > } > > } > > , messages: { > > remote: '* Error' > > } > > }); > > var isNameValid = txtName.valid() > > return isNameValid; > > } > > > The problem I have is that .valid() always returns false - because it > > doesn't wait for theremotevalidationGET to complete. Hence > >validationfails. Any suggestions? How do people normally doremote > >validationin jquery? > > > Note: I know for sure that validate.ashx returns true. > > > Thanks in advance.