[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

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.
0
sanjshah12
Asked:
sanjshah12
  • 3
  • 3
1 Solution
 
leakim971PluritechnicianCommented:
if(/&|'/.test(fld.value)) {
   alert("Your file contains invalid characters, please rename your file.");
   fld.focus();
   return false;
}
return true;
0
 
sanjshah12Author Commented:
thanks leakim971,

just to check I need to ensure that &-,'/% are not contained in the filename - so I added:

      if(/&|'|-|,/.test(fld.value)) {

but don't think that I'm doing this correctly.


0
 
leakim971PluritechnicianCommented:
Instead use :

 if(/[&'\-,]/.test(fld.value)) {
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
sanjshah12Author Commented:
Thanks that works!
0
 
sanjshah12Author Commented:
thanks leakim971 for the links.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now