Simple Javascript help

Teensweb

New Member
Messages
352
Reaction score
1
Points
0
I have a js for a form validation
HTML:
<script type=text/javascript>
function validate_form ( )
{
    valid = true;

    if ( document.form1.file_name.value == "" )
{
        document.form1.file_name.style.border = '2px solid #ff0000';
        document.form1.file_name.focus();
        valid = false;
    }
return valid;
}
</script>
Now what I need is: The border it draws is of zero padding that is, it covers my input also. I wanna set a padding to it so that it keeps 1 px distance from the input.
 
Last edited:

Hazirak

New Member
Messages
197
Reaction score
0
Points
0
I think what you're looking for, if you want to do it through JavaScript, is "document.form1.file_name.style.padding = '1px';"... or however much padding you need.

You can also use other units of measurement if you want, such as cm, in, em, percentages, etc.
 
Last edited:

Hazirak

New Member
Messages
197
Reaction score
0
Points
0
You'll have to put the input box in a container of some sort, such as <span><input /></span>, and then set the border and padding of the span tag.

You could probably also just set the border and padding of the paragraph tag the input tag is in. That may or may not require you to actually close the paragraph tags, though if I'm not mistaken, most browsers assume one paragraph tag closes when another begins.
 
Top