Avatar of sanjshah12
sanjshah12
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Check if field contains certain characters

Hi,

Is it possible to check if a field contains certain characters, I thought I could use the following:

I'm checking for & , '

if(!/(\-|\&|\')$/i.test(fld.value)) {
alert("Your file contains invalid characters, please rename your file.");
fld.focus();
return false;
}

Thanks in advance.
JavaScriptJScript

Avatar of undefined
Last Comment
sanjshah12

8/22/2022 - Mon