views:

41

answers:

0

Googled and found nothing, might be asking the wrong question but here goes.

How do I add padding/margin on a element that is invalid?

I'm using jQuery validate plug-in to validate user input and required fields (As well as some PHP server side validation). The fields are in the middle of the web-page so when the validation happens it sets the focus on that element, but since the element is in the middle of the web-page it sets focus on the element and brings it to the top of the browser

Example:

<div>
<label for="name">Name</label> <!-- on error this is not show on the web-page unless you scroll up -->     
<input type="text" name="name" id="name" tabindex="3" />
</div>

If there is an error with name the focus is set on the text input and the label is not show unless you scroll up a little.

Wanted to know if I could add padding or something to show the label as well?

Found this while looking but don't know how to implement this

$("#error_label").attr("tabindex",-1).focus();