validate the path in javascript
How can I validate a folder path in javascript?
For example, if I enter the path:
c:\myf开发者_开发知识库older\hi\
it must be validated to some expression saying user must input the path as:
c:\\myfolder\\hi\\
Users may specify a path of any length.
I would try the following regular expression:
if (user_given_string.match(/^[a-z]:(\\\\([a-z]+))*\\\\?$/i)) { OK } else { wrong }
if(path.match(/^[a-z]+\\/|\\){1,2}([^\/\\\<\>\:\"\?\|\*]+(\/|\\))*[^\/\\\<\>\:\"\?\|\*]+\.[a-z]+$/i))
{
true;
}
else
{
false;
}
精彩评论