|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all,
Can anybody tell me how to read the first 6 characters of Text-box? I think I have to use indexOf but don't know how it works URL Greetz, Henk Emmelot |
|
#2
|
|||
|
|||
|
Moin Henk,
indexOf() is not the function that matches your question. The question for indexOf() is "does the string contain this substring". Your question is "give me the first n characters". This is a job for substr(). (pseudo code!) n = 5; sub = ""; value = document.forms.elements[..].value; if (""!=value && value.length>=n) { sub = value.substr(0,n); window.alert(sub); } Ulf |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Reading the first 6 characters of a Text-Box |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|