I want to validate my file name for whitespace before attaching it to a sharepoint list. Here is my code
Expand|Select|Wrap|Line Numbers
- <Script type="text/javascript">
- function PreSaveAction()
- {
- var attachment;
- var filename="";
- var fileNameSpecialCharacters = new RegExp("\\s", "g");
- try {
- attachment = document.getElementById("idAttachmentsTable").getElementsByTagName("span")[0].firstChild;
- filename = attachment.data;
- }
- catch (e) {
- }
- if (fileNameSpecialCharacters.test(filename)) {
- alert("Please remove the special characters from the file attachment name.");
- return false;
- }
- else {
- return true;
- }
- }
- </script>
Expand|Select|Wrap|Line Numbers
- var fileNameSpecialCharacters = new RegExp("[~#%&*{}<>;?/+|\"]");
Can anybody help?
BR,
Sijo
This reg