Try changing within to $('form').

I haven't come across within so I don't know anything about it.

On Sep 29, 4:45 pm, Jeremy <jeremy.darl...@gmail.com> wrote:
> I have built out a fairly rhobust app using jquery and jquery-ui all
> was going well until we started to bring different screens together
> inside a tabbed interface.  Seems that now when we execute our
> validation code on one form its checking the fields of all other forms
> on the page.
>
> All of my forms do have unique ID's and all elements within all forms
> have unique ID's.
>
> My understanding of using this.find inside of the submit event was
> that it should only find the forms elements am I wrong?
>
> Method that performs the actual validation:
> function validateForm(event){
>   var allOk = true;
>   $(this).find("*[validation]").each(function(){
>     var elem = $(this);
>     var val = elem.attr('validation');
>     var fn = elem.attr('id');
>     var ok = true;
>     if(val!='') eval('ok = '+val+';');
>     ok = (ok)?true:false;
>     if(allOk&&(!ok)) elem.focus();
>     if(ok) elem.removeClass('error');
>     else{
>       elem.change(function(){
>         var elem = $(this);
>         var fn = elem.attr('id');
>         var val = elem.attr('validation');
>         var ok = true;
>         if(val!='') eval('ok = '+val+';');
>         if(ok) elem.removeClass('error');
>       });
>       elem.addClass('error');
>     }
>     allOk = allOk && ok;
>   });
>   this.valid = allOk;
>   if(!allOk) if(event) event.preventDefault();
>   return allOk;
>
> }
>
> Initialized with (inside document.ready):
>   within.find("form").submit(validateForm);
>
> Thanks,
>  - Jeremy

Reply via email to