Olivier Percebois-Garve escribió:
Hi

So far I have been able to make custom error boxes with the following code:
              $(".error").each(function(i, n){
$formElement = $(n).next('input, select');
                                $offset = $formElement.offset();
$left = $offset.left+$formElement.width()+$formElement.parent().next(".error_exclamation_mark").width();
                                $top = $offset.top;
$(n).wrap("<div class=\"errorBox clearfix\"></div>"); $(n).before('<div class=\"errorBoxTitle\">Error</div>'); $formElement.after('<div class=\"error_exclamation_mark\"></div>'); $formElement.wrap('<div class=\"errorFormElement"></div>'); $(n).parent(".errorBox").css('position', 'absolute').css('left', $left).css('top', $top);
                              });

Open issues with that are :
- the code is being runned each time I hit the submit button, so the error boxes are are duplicated.
 I dont know how to make it run just once.
-my dimension code get some positions wrong, I cant tell where it comes from.

jQuery.YAV remove automatically before the next validation the old error tags, but you wrap the errors inside an another DIV (errorBox) so this is not removed. Analizing your code, I think that you are trying
something like this example, maybe?:

The rules sets:
NAME: required
HOTMAIL: implies pre-condition if checked then HOTMAIL ACCOUNT must pass the regexp expression.

I don't need move the error messages into absolute position. The messages are removed in each validation without duplication problems, I can set the exclamation mark and the errorBoxTittle and the more important, I don't need wrap any input element into to another DIV for to change the CSS of the field on error.

http://projects.sevir.org/storage/yav/moreimpliesexample.html

The JS code:
   $(document).ready(function(){
       $("#myform").yav({
           errorPositon: "before",
           errorTag: "div",
           errorClass: "errorBox",
           onError: function(){
               $(".errorBox").each(function(){
                   $(this).html(
                       '<div class="errorTitle">ERROR</div>' +
                       '<div class="errorContent">'+$(this).html()+'</div>'
                   );
               });
               return false;
           }
       },{
           inputclasserror: "errorFormElement"
       });
   });



But that is peanuts compared to the pain of getting the "implies" rules to work.
I just broke my head on that the whole afternoon and feel very frustrated.

The rules syntax seem easier on the yav website.

Sevir, you may want to add examples on your website.
If I can give some constructive critics:
-The code in the "alt" attribute may be indented. its just too long to read. -Each example should have only one specific thing: for instance http://projects.sevir.org/storage/yav/relationships.html
 that page demonstrates a relation + a custom rule.


Ok, I will see that, thanks for your suggestions.
Ok, that's what I can say for now, my brain is smoking ;-(

-Olivier


--
Best Regards,
José Francisco Rives Lirola <sevir1ATgmail.com>

SeViR CW · Computer Design
http://www.sevir.org
Murcia - Spain

Reply via email to