Jump to content

Validating string for MY keyboard charset only minus GT and LT


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';
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.