I suggest disabling the submit button so the user won't be surprised when
clicking it has no affect.
--
Hector


On Mon, Jul 20, 2009 at 12:59 PM, James <james.gp....@gmail.com> wrote:

>
> The code you provided is just the check when the field has the blurred
> event called. Are you also doing the check when the form is submitted?
> You have to do some kind of check on form submit, and if it doesn't
> pass, do a "return false;" and the form should not be submitted.
>
> On Jul 20, 2:28 am, psykeeq <ales.fa...@gmail.com> wrote:
> > So I have a JQuery/ajax username availability check function which
> > calls a file check.php that scans the database  for existing username
> > and lets you know if the one typed in is occupied or not. And this
> > availabilty check is inside a registration form witch has some simple
> > validation rules like required password, required email... The only
> > think that is getting me frustrated is that even if the uname function
> > says that the "username is not available" the form lets me through and
> > I can still press the submit button and go to the next page.
> > So I want my form not to validate if this function tells that the
> > username is not available.
> > I tried to create a custom rule and some other things but I couldnt
> > get it done so if somebody could help me it would be really great. tnx
> >
> > $(document).ready(function()
> > {
> >         $("#uname").blur(function()
> >         {
> >                 $("#msgbox").removeClass().addClass('messagebox').text
> > ('Checking...').fadeIn(1000);//remove all the class add the messagebox
> > classes and start fading
> >                 $.get("check.php",{ uname:$(this).val() }
> ,function(data)//check the
> > username exists or not from ajax
> >         {
> >                   if(data=='no') //if username not avaiable
> >                   {
> >                         $("#msgbox").fadeTo(200,0.1,function() //start
> fading the
> > messagebox
> >                         {
> >                          $(this).html('This User name Already
> exists').addClass
> > ('messageboxerror').fadeTo(900,1); //add message and change the class
> > of the box and start fading
> >                         });
> >           }
> >                   else if(data='yes')
> >                   {
> >                         $("#msgbox").fadeTo(200,0.1,function()  //start
> fading the
> > messagebox
> >                         {
> >                           //add message and change the class of the box
> and start fading
> >                           $(this).html('Username available to
> register').addClass
> > ('messageboxok').fadeTo(900,1);
> >                         });
> >                   }
> >         });
> >         });
>

Reply via email to