Statistics
| Branch: | Tag: | Revision:

root / astakos / im / static / im / grnetstyles / js / form-errors.js @ 13858d75

History | View | Annotate | Download (669 Bytes)

1
(function($){
2

    
3
  $.fn.formErrors = function(options) {  
4
    return this.each(function() {
5
        var $this = $(this);
6
        var errors = $this.find(".errorlist");
7
        if (errors.length == 0) {
8
            return;
9
        }
10

    
11
        var el = $('<div class="form-error" />');
12
        errors.find("li").each(function(){
13
            el.html(el.html() + $(this).text() + "<br />");
14
        })
15

    
16
        $("body").append(el);
17
        var left = $this.offset().left + $this.width() - 20;
18
        var top = $this.offset().top + el.height()/2 - 2;
19

    
20
        el.css({left: left + "px", top: top + "px", width: 'auto'});
21
        errors.remove();
22
    });
23

    
24
  };
25
})( jQuery );