I have function like this:
var name_regex = /^[a-zA-Z0-9_ -]{3,32}$/,
body_regex = /^[a-zA-Z0-9_ -]$/,
email_regex = /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/,
phone_regex = /^[0-9-]{3,32}$/,
error_count;
function validation_test (name, value) {
var test_name = name + '_regex';
console.log(test_name);
error_count = 0;
if(!test_name.test(value)){
error_count += 1;
}
}
And if I try to run it (on submit) I get following error:
test_name.test is not a function
console.log(test_name) is giving me the proper name for the variable (for example name_regex). How can I make this variable work?