
September 21st, 1999, 04:40 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
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
|