Monday, November 30, 2009

[jQuery] Validate: a question about the Remote option

Hello everyone,

I'm still dealing with that signup form.
Now I'd like to check with an Ajax call if a login is already taken.
That's what I'm doing:

$("#signup").validate( {
rules: {
ulogin: {
required: true,
// It's a custom method checking a regexp, it's working
login: true,
rangelength: [3,20],
remote: "check.php?w=1"
},
...

Here's the check.php file:

// Including the connection file, blah blah
...
$valid=true;
// Since I'm planning to use this file as a multipurpose script,
//preventing it from stop working
if (!isset($_REQUEST['w'])) $_REQUEST['w']=1;
if ($_REQUEST['w']==1) {
// If the login is taken, it will return something >0
$number=mysql_num_rows(mysql_query("SELECT `Id` FROM `Users` WHERE `Login`='".$_REQUEST['ulogin']."'", $link));
if ($number>0) $valid=false; else $valid=true;
}
After I validate, it stops working: it says incorrect for all fields
after the second submit. After the first submit it says nothing, even
that the login is already taken.
What's wrong?
Thanks!

--
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

No comments: