Assuming (as I believe you've indicated) that you know how to both get and set the value of the text box and/or do whatever it is you want to do with the value of the text box - say the value of the text box is now in a declared var named str:
Code:
str = str.replace(/\/[^\/]*$/, '/');
ex:
Code:
var str = 'c:/program files/new folder';
str = str.replace(/\/[^\/]*$/, '/');
alert(str);
The above will alert:
Edit:
There is another way:
Code:
var str = 'c:/program files/new folder';
str = str.substring(0, str.lastIndexOf('/') + 1);
alert(str);
Same result. However, there is a difference. With the first method if there is no / in the string, the entire string will be preserved. Using the second method, if there is no /, you will be left with an empty string. So if that matters, pick the one that best suits your purposes.
Bookmarks