Is there a way for me to validate the filename for any special characters and cancel the upload if it contains any special characters?
1 Answer, 1 is accepted
0
Ivan Danchev
Telerik team
answered on 24 Sep 2015, 11:13 AM
Hello,
You can subscribe to the AsyncUpload's OnClientFileUploading client-side event, in its handler check the filename for presence of special characters and cancel the the event in case such are found:
function OnClientFileUploading(sender, args) {
var filename = args.get_fileName();
var dotIndex = filename.lastIndexOf(".");
var name = filename.substring(0 , dotIndex)
if (/^[a-zA-Z0-9- ]*$/.test(name) == false) {
alert('The filename contains special characters. The upload will be cancelled.');
args.set_cancel(true);
}
}
Regards,
Ivan Danchev
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items