Jump to content

Validating string for MY keyboard charset only minus GT and LT


sKunKbad

Recommended Posts

I'm trying to validate a string, but it isn't working. It's probably the regex... but I copied and pasted it from php. So there's probably a difference between the way php uses this regex vs. javascript. Can somebody point out the error please:

 

var myMesgRegex = /^[^-\s A-Z0-9~!@#$%^&*()_+=;:\'",.?|}{[\]\/\\\\]*$/i;
var matchPos3 = mesg.search(myMesgRegex);
if (mesg !== ''){
if (matchPos3 !== -1){
	mesgIsGood = 'yes';
}else{
	mesgIsGood = 'no';
}
}else{
mesgIsGood = 'no';
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.