Reputation: 1457
I am creating folders based on the name given by the user in text box from code behind in asp.net. Now I want to validate the name entered by the user before creating the folder. I want to validate the name on client side preferably (like using javascript or jquery).
Upvotes: 0
Views: 586
Reputation: 62246
You have to do the check on server side and/or on client side too. For client side you may think about some simple regular expression, on server side you can use Path.GetInvalidPathChars
and check if provided by user string contains any of them.
Remember only that on client side could be different OS es, so also a set of valid characters in file name can vary, so what you can do is just use only set valid for OS you use on server side.
Upvotes: 2