check a string if contains symbols js code example
Example 1: how to check for special characters in javascript
var format = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]+/;
if(format.test(string)){
return true;
} else {
return false;
}
Example 2: js check if string contains character
if (your_string.indexOf('hello') > -1)
{
alert("hello found inside your_string");
}