Forum Moderators: open

Message Too Old, No Replies

problem in string breaking using javascript

string break in javascript, string break, explode string in javascript,

         

mannbaig

7:49 am on Jan 31, 2008 (gmt 0)

10+ Year Member



I am using the substr() and substring() javascript both functions in my code I have to choose the extenssion of file.
I am using it as:
1 - form.field.value.substr(-3);
2 - form.field.value.substring(-3);

it is working in firefox but not working in IE-5,6.

Please help me thanks.

Fotiman

4:28 pm on Jan 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



substr(start, length)
substr can take a negative number as the start index. -1 specifies the last character, -2 the second-to-last character, and so on.

substring(from, to)
substring takes an integer that specifies the position within the string of the first character of the substring. It must be between 0 and the string length - 1.

Therefore, substring(-3) is not valid use of substring.