Sasha
Sasha

Reputation: 20834

another Bug in jquery validator?

i use remote method of validator for checking if username exists in DB

my scenario:

  1. form with one field (username of course)
  2. i filled field
  3. it passes validation, but i don't sending form yet
  4. going to DB inserting username that i filled in form that i still don't sent yet
  5. returning to my form press on submit btn
  6. voila, it pass validation (here the issue if u don't understand yet)

of course i did validation on the server side too, but it will be great that validation for remote method will fire too when sending form

p.s. i'm using 1.5.5 version but see that this issue still exists

Upvotes: 0

Views: 453

Answers (1)

Jab
Jab

Reputation: 13775

If I'm reading this properly, jQuery is not at fault here.

If this isn't correct let me know. I am imagining a registration form.

I go to your form, enter a username. jQuery says the username is available using the remote validation technique.

Before I click submit, someone else submits the same form with the same username, and gets it.

I can still submit the form, even though I have an already taken username.

This is a classic scenario. A concurrency problem. The data is now stale that was pulled by jQuery validation during my registration. You need to adjust for this scenario in your remote page or make jquery validation run on form submit as well. You could just call validate() on your form in the submit method of your form.

Upvotes: 2

Related Questions