this is my RegExp
function wordInString(s, word){
return new RegExp( '\\b' + word + '\\b', 'i').test(s);
}
var about=jQuery('#compdesi').val();
var education=jQuery('#educationhistory').val();
if((wordInString(about, '@')==true) || (wordInString(about, '.com')==true) || (wordInString(about, '.co')==true) || (wordInString(about, '.org')==true) || (wordInString(about, '.net')==true) || (wordInString(about, '.info')==true) || (wordInString(about, '.au')==true) || (wordInString(about, '.uk')==true) || (wordInString(about, '.ac')==true))
{
alert("You can not enter website, email or phone number in about");
return false;
}
this is blocking Both UK,com and .UK .com what M i doing wrong !
m using test as text :-
was born into a family of artists in mial in UK. he had a deep impact on his painting. now regularly in Africa.
Like dystroy says, except you need to double escape, try this line instead:
if ((wordInString(about, '@'))
|| (wordInString(about, '\\.com'))
|| (wordInString(about, '\\.co'))
|| (wordInString(about, '\\.org'))
|| (wordInString(about, '\\.net'))
|| (wordInString(about, '\\.info'))
|| (wordInString(about, '\\.au'))
|| (wordInString(about, '\\.uk'))
|| (wordInString(about, '\\.ac')))
.
in a regex means "any character".
Use "\\.uk"
Change this function to:
function wordInString(s, word){
return new RegExp( '\\b\\\\' + word + '\\b', 'i').test(s);
}