Search code examples
jqueryasp.netweb-servicesjquery-validation-engine

JQuery ValidationEngine making AJAX calls to vb.net Web Service


I've looked into the documentation examples given at the Plugin's home page and the AJAX examples don't seem to be working.

In addition, all the examples I've seen have been for PHP/JAVA/ETC.

What I'm really looking for is a simple example using the JQuery Plugin ValdiationEngine using an AJax type validator which checks against a VB.NET web Service. Which files need to be modified? Or can it all be done from within the page with the validator on it. Is there any specific format that the webservice needs to return, etc.

Here is the plugin in question: http://posabsolute.github.com/jQuery-Validation-Engine/


Solution

  • We use this for an ajax validation rule that calls an ASP.Net web setvice. All you have to do is write the rule in your language file.

    Here's ours:

    "ajaxEmailCheck": {
        "url": "/json_api/AjaxEmailCheck/",
        "extraDataDynamic": ['#EmailAddress'],
        "alertText": "* An Account with this email has already been created.",
        "alertTextLoad": "* Validating, please wait..."
    },
    

    This one calls the url /json_api/AjaxEmailCheck and passes the Email address. Then our field is defined like this:

    <input type="email" 
           name="email_address" 
           title="Email Address" 
           id="email_address" 
           class="validate[required,custom[onlyLetNumSpec],ajax[ajaxEmailCheck]] 
    />
    

    Also, here's the onlyLetNumSpc rule used above:

    "onlyLetNumSpec": {
        // Good for database fields
        "regex": /^[^\\]+$/,
        "alertText": "* Any Character is allowed with the exception of backslash(\)."
    }
    

    The data returned from the web service looks like this:

    "{"EmailAddress":true}"
    

    And if the email passed already exists:

    "{"EmailAddress":false,"Error":"* An Account with this email has already been created."}"