Attached File Name (Unicode Characters) Validation in JQuery, Javascript
");
var InvalidFileName = true;
var OriginalValue = ''
$("#HTMLListItemID").empty();
$(".txtValidationTextBox").each(function () {
OriginalValue = $(this).val();
if (OriginalValue != '') {
var rgx = /[^\u0000-\u007F]/g;
var temp = $(this).val().replace(rgx, ' ');
var tempFileName = temp.substring(0, temp.lastIndexOf('.'));
var FileExtension = temp.substring(temp.lastIndexOf('.'), temp.length);
var tempFileNameTrimmed = tempFileName.trim();
if (tempFileNameTrimmed != '')
$(this).val(tempFileNameTrimmed + FileExtension);
if (temp != '' && tempFileNameTrimmed == '') {
InvalidFileName = false;
$("#HTMLListItemID").append("
The Attachment File Name ("
+ OriginalValue + ") is invalid.
}
}
});
return InvalidFileName;
No comments:
Post a Comment