Node.js Editor - Regex Validation possible
Node.js Editor - Regex Validation possible
I want to regex validate some input fields with editor node.js. Is this possible? For instance is this example working?
new Field("name")
.validator((val, data, host) => {
if(val === null){
return true;
} else {
return val.match("/^[a-zA-Z ]+$/")
? 'Not valid!'
: true;
}
})
This discussion has been closed.
Answers
I don't think you want the regex expression in quotes. I believe it should look like this:
return val.match(/^[a-zA-Z ]+$/)
.Kevin