I'm trying to add a regular expression inside a JavaScript function. I've never done something like this before. How is this done? I've got the length part correct, but the regex has me stuck.
if(searchTerm('Ford GT')) {
alert ('Query OK');
} else {
alert ('Invalid query');
}
function searchTerm(query) {
if( (query.length >= 2 && query.length <= 24) && (query.test('/^[a-z0-9()\- ]+$/i')) ) {
return true;
} else {
return false;
}
}