On 09/03/07, Rick Faircloth <[EMAIL PROTECTED]> wrote:
> Oh, very, very close, Sam!
>
> I finally saw an error message appear above my
> form fields. Yay!
>
> However... now the form field below the message drops
> down when the message appears (which is not really a problem),
> but when the correct entry is made and the error message
> disappears, the form field label remains out of alignment.
>
> In other words it starts out like this:
>
> Principal [Principal Form Field]
> Interest Rate [Interest Form Field]
> Years [Years Form Field]
>
> If I remove the pre-filled number from the Principal field,
> the error message pops up and this is the display:
>
> Principal "Please enter the principal."
> [Principal form field]
>
> That would be ok, but after the correct entry is made it looks like this:
>
> Principal
> [Principal form field]
>
> If error are entered and error message displayed for all fields,
> I eventually end up with a form with fields that display like this:
>
> Principal
> [Principal form field]
> Interest Rate
> [Interest form field]
> Years
> [Years]
>
> Is there any way to tweak your code to cause the form elements
> to "reset" to their original positions after an error message appears
> and then is removed?
>
> Rick
You could probably use CSS for that, but before you do, errorPlacement
needs to change (i.e. don't add the <br>)
errorPlacement: function(error, element) {
$(element).before(error);
},
And your CSS:
label.error {
position: relative;
margin-top: -1em;
}
The problem with that is that it may obstruct some text or an input
above (without seeing how your page looks, there is no way to know).
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Sam Collett
> Sent: Friday, March 09, 2007 10:04 AM
> To: jQuery Discussion.
> Subject: Re: [jQuery] Options for Validation...
>
>
> I think I got it mixed up:
>
> errorPlacement: function(error, element) {
> $(element).before(error).before("<br>");
> },
>
> This should add the error before the element and then a break (so it
> appears directly above)
>
>
>
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/