How do I force section to be either asd or alg or sys or data or sim or se ?
If I use regex like below, then datadfghdg would be allowed.
if (section == '') {
alert('Section is required');
} else if (!(/asd|alg|sys|data|img|se/.test(section))) {
alert('Section must be one of: asd alg sys data img se');
} else {
is_okay = 1;
}
You can force the strings to be at the beginning and and of the regex by using
^and ^$` respectively:Alternatively you can use
into achieve this as well: