1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

jquery validate plugin with ajax duplicate check

jQuery validate plugin is pretty awsome. However it doesn’t do everything. That’s why the plugin have the addMethod function. And I need to add an ajax duplicate check for an email input. Here’s the method i wrote. There might be a better way. I would love to know.

jQuery.validator.addMethod("checkForDupeEmail", function(value, element, param){

var ajaxFunc = $.ajax({
async:false,   //we have to set it to false, it does not return a value before we even complete the request.
data:'email='+($.trim(value)),
type:'POST',
url:'/employees/ajax_checkDupe',
dataType:'text',
});
//here we check the response


if(ajaxFunc.responseText == 1)

return >true;

else

return >false;
});
Share:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • MySpace
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Twitter
  • Yahoo! Bookmarks
  • #1
    Posted by Tabblettochka on October 16th, 2009 at 6:46 AM

    И придратся не к чему, а я так люблю покритиковать…

Share your opinion! Post your thoughts.