Jorn, I've been looking at the remote method of your Validation plugin, but was wondering if its possible to send all fields in a form and return the error within the php validation file like so:
<?php $request = trim(strtolower($_REQUEST['value'])); $emails = array('[EMAIL PROTECTED]', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]'); $valid = 'true'; foreach($emails as $email) { if( strtolower($email) == $request ) $valid = array('email_address' => $request.' is not a valid email address'); } else { $valid = array('email_address' => 'true'); } echo $valid; ?> I may have to implement my own here as it has a specific/ varied purpose. On Oct 31, 9:56 am, "Jörn Zaefferer" <[EMAIL PROTECTED]> wrote: > Currently I can only recommend to look at the implementation of the > remote method, and replicate whats there. Its rather complex and it > would be nice to refactor it to make this easier - your help is > welcome. > > Jörn > > > > > > On Thu, Oct 30, 2008 at 7:46 PM, w1ntermut3 <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I need to do some AJAX-based validation to check that the email > > address entered isn't in the database already, but only if the "I am a > > new user" radio button has been checked. > > > I know that the Validation plugin has a "remote" rule, and rules that > > can validate one element based on the value of another. But I couldn't > > work out how to combine those two, so I tried rolling my own method: > > > $.validator.addMethod("non-duplicate-email-for-new-customer", > > function() { > > // If customer is new, check the email address isn't in the > > database > > already > > var passValidation = true; > > var sEmail = $('#txtEmail').val(); > > var iCustType = > > $('input[name="radCustomer"]:checked').val(); > > if ((sEmail!='') && (iCustType == 1)){ > > console.log("checking"); > > $.get("_ajax_emailexists.asp", { email: sEmail }, > > function(data){ > > console.log("data:" + data); > > passValidation = (data=='true') ? true : > > false; > > console.log("passValidation:" + > > passValidation); > > return passValidation; > > }); > > } > > console.log("returning " + passValidation); > > }, "This email address is taken."); > > > This doesn't seem to be working. Describing exactly what it's doing is > > a little tricky, and I suspect that if I could, I'd be able to figure > > out what was wrong with it. But I think it might be returning before > > the AJAX call has completed. In any case, it constantly returns true > > and the error message is constantly displayed. > > > Is this a simple fix or am I going about this the wrong way?