How to check the border style of an input field?

M

Mad Joe

For some reason, I have to change border style of an input field
frequently, and I'd like to make some events (onFocus & onBlur)
depending of the style of border of that input.

The following code is not working, but how to change it to make it possible?

<input name="name" type="text" id="name" value="0"
onFocus="if (this.style.borderBottomStyle == 'dashed') this.value='X'"
onBlur="if (this.style.borderBottomStyle == 'dashed') this.value='Y'">
 
M

Mad Joe

Border style is changing dynamicaly, like this:

document.forms[0].elements.style.border = "#bbb 1px dashed";
 
R

RobB

Mad said:
Border style is changing dynamicaly, like this:

document.forms[0].elements.style.border = "#bbb 1px dashed";


Diego said:
Was the border style set by scripting or CSS?


Works fine (although 'name' is a bad, erm, name for an identifier).
Post a fuller example if possible, might be something you're
overlooking.
 
D

Diego Vilar

In the first post, you were querying .borderBottomStyle, but in the
last one you said you were setting the border style through .border. If
you're changing .border, don't think it's gonna reflect on
..borderBottomStyle, since they are 2 different properties

..border affects all sides of the object, but that doesn't mean it
changes
..borderBottomStyle, .borderTopStyle, .borderLeftStyle and
..borderRightStyle readings.

Diego
 
M

Mad Joe

You're right, Rob! Everything's fine... I overlooked something.
About the name='name'... even if that was just an example, it also works
with it, no prob.

Thanks anyway!
 
R

RobB

Diego said:
In the first post, you were querying .borderBottomStyle, but in the
last one you said you were setting the border style through .border. If
you're changing .border, don't think it's gonna reflect on
.borderBottomStyle, since they are 2 different properties

.border affects all sides of the object, but that doesn't mean it
changes
.borderBottomStyle, .borderTopStyle, .borderLeftStyle and
.borderRightStyle readings.

Diego

Diego...lol, that's the first thing I thought of ('no cascading in the
DOM') so I typed out an authoritative answer...then thought better of
it and and tested. Oops...it does update the individual properties
(iewin, FFwin, saf-osx).
 
D

Diego Vilar

Oops... should have checked that first.. lol.... I just sorf of had in
memory this situation where something alike happened and had something
to do with that, and so I went straight to the authoritative answer..
rsss.. my bad... sorry for that ;)

Diego
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top