Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added asyncFuncCall - Validates a field using an asynchronous third party function #783

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jkapelner
Copy link
Contributor

Validates a field using an asynchronous third party function call. This behaves similarly to funcCall, but the external function is an asynchronous function - it does not return anything. Instead it must call a callback with the validation result (true if success, false if failure) and an optional message to display. This allows you to validate anything asynchronously (i.e. call ajax, call some 3rd party library, use websockets, etc.)

function checkHELLO(field, rules, i, options, callback){
  setTimeout(function(){
    if (field.val() === "HELLO") {
      callback(true);
    }
    else {
      var msg = options.allrules.validate2fields.alertText; // this allows to use i18 for the error msgs
      callback(false, msg);
    }
  },2000);
}

The following declaration will do

<input value="" class="validate[required,asyncFuncCall[checkHELLO]]" type="text" id="lastname" name="lastname" />

@gregorypilar
Copy link

HI,
Change is merge with the main source??

@jkapelner
Copy link
Contributor Author

Hi. I haven’t touched it in a while so it’ll need to be merged. I can do that this week.

From: Gregory Pilar [mailto:notifications@github.com]
Sent: Thursday, April 02, 2015 1:19 PM
To: posabsolute/jQuery-Validation-Engine
Cc: jkapelner
Subject: Re: [jQuery-Validation-Engine] added asyncFuncCall - Validates a field using an asynchronous third party function (#783)

HI,
Change is merge with the main source??


Reply to this email directly or view it on GitHub #783 (comment) . https://github.com/notifications/beacon/ABkWYmDkaENpL7TMAwWaCXmXwac2HMJlks5n7XGNgaJpZM4Bpl07.gif

@gregorypilar
Copy link

Thanks ! , I will appreciate that

@jkapelner
Copy link
Contributor Author

ok I merged and updated it.

@gregorypilar
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants