I have contacts field in the page where the user must fill in, for example, the name, he should just type letters, in the phone field, just numbers and email required to use the "@". The idea is to display a message to the user when they enter number in the "name" field and so on.
I was able to capture the user input, but the regular expression does not work.
This is my code:
var validaNome = $("#input-nome");
validaNome.on("input", function(){
var digitado = validaNome.val();
var comparavel = new RegExp("ab+c");
if(digitado <= comparavel){
$(".digite-nome").css("display", "none");
}else {
$(".digite-nome").css("display", "block");
};
});
The comparable variable receives the regular expression and then uses it in the validation.
Can anyone help me? Or is there another way to validate this?