![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Daviso said the following on 2/3/2006 6:36 AM: Hi. I hava an input like this td><input name=numberA> </td and a button with a javascript function in onclick event. I want to control that the first element of the value I have introduced in numberA will be different and make a conditional for example 43543, I want to control the first digit (4) 5433, I watn to control the first digit(5) I'm using "substring" but it seems doesn't work I have: If (document.F.numberA.value.substring(1,1) == "4") or If (document.F.numberA.subtring(1,1) == "4") but no way. How can I do this???? if != If. JS is case-sensitive. But, if all you want is the first character, charAt might be a better solution: if (document.F.numberA.value.charAt(0) == "4") if (document.F.numberA.value.charAt(0) == "5") -- Randy comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ |
#3
| |||
| |||
|
|
Hi. I hava an input like this td><input name=numberA> </td and a button with a javascript function in onclick event. I want to control that the first element of the value I have introduced in numberA will be different and make a conditional for example 43543, I want to control the first digit (4) 5433, I watn to control the first digit(5) I'm using "substring" but it seems doesn't work I have: If (document.F.numberA.value.substring(1,1) == "4") or If (document.F.numberA.subtring(1,1) == "4") but no way. How can I do this???? |
#4
| |||
| |||
|
|
43543, I want to control the first digit (4) 5433, I watn to control the first digit(5) I'm using "substring" but it seems doesn't work I have: If (document.F.numberA.value.substring(1,1) == "4") or If (document.F.numberA.subtring(1,1) == "4") |
#5
| |||||
| |||||
|
|
I hava an input like this td><input name=numberA> </td |
|
and a button with a javascript function in onclick event. I want to control that the first element of the value I have introduced in numberA will be different and make a conditional for example 43543, I want to control the first digit (4) 5433, I watn to control the first digit(5) I'm using "substring" but it seems doesn't work I have: If (document.F.numberA.value.substring(1,1) == "4") or If (document.F.numberA.subtring(1,1) == "4") |
|
SyntaxError: missing ; before statement |
|
TypeError: document.F.numberA.value.substring is not a function |
|
but no way. How can I do this???? |
![]() |
| Thread Tools | |
| Display Modes | |
| |