Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to add another clause

Status
Not open for further replies.

MrPantsTm

Programmer
Jan 22, 2004
71
0
0
US
At the moment I have this in my text box form:

onfocus="if (this.value=='0') this.value=''"

I'd like to keep this but also add a clause so that it returns it to 0 (or blank but 0 would be more helpful) if it goes out of range (say 10). How would I combine the two? TIA
 
You mean like this?

[tt]
onfocus="if (this.value == 10 || this.value > 10) {this.value = '0';}"
[/tt]

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
one other thing. how would I signal the text area to say change color to red so to signal the user?
 

Try this:

[tt]onfocus="if (this.value == 10 || this.value > 10) {this.value = '0';this.style.color = 'red';[/}"[/tt]

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top