Jquery error posting

I have a jquery form. the checks are working correctly, but I want the bug to be posted correctly. right now it displays in IE 7 as:

alt text http://img412.imageshack.us/img412/1810/errorhma.jpg

but I would like to display it like:

alt text http://img520.imageshack.us/img520/7089/error1ace.jpg

this is the css code:

div.error { display:none; }
           <%-- input { border: 1px solid black; }--%>
            input:focus { border: 1px dotted black; }
            input.error { border: 2px solid red; }
            label.error { color: white; font-size:16px; font-family:Nyala; background-color: red }
            label.valid { color: green; }

      

+1


a source to share


3 answers


try label.error {display: block;}



+4


a source


You can control the placement of the error message using errorPlacement. The default is "error.insertAfter (element)". You can use one of them, for example:

errorPlacement: function(error, element) {
    error.insertBefore( element );
    //error.appendTo( element.parent().next() );
    //error.appendTo(label.insertAfter( element ));
    //error.insertAfter(element.sibling(a));
}

      

or even put some condition here and use other statements:



errorPlacement: function(error, element) {
    if ( element.is(".something") ) {
        element.nextAll('div').html(error);
    } else {
        error.insertAfter( element );
    }
}

      

Hope it helps

+3


a source


There are several problems, first, that the error coloration is shown as surrounding the input element. So either you need to use an error div to contain the input element, or just change the container color for the form element. I vote to change the container color.

Secondly, you want the div.error to be transparent on the left and right (assuming you are just changing the container color for the form element), so just add:

div.error {
  clear: both;
}

      

This assumes that for some reason you swam to the left. Anyway, see a simple example of how to lay it out

http://jsbin.com/amaxa

+1


a source







All Articles