The subject exists but I don't understand here: (I am beginner)
Check whether a string matches a regex in JS
In fact, I have a form name
, in my validation I would like to avoid that the user enters numbers or symbols.
function validation()
{
const name = document.getElementById('name').value;
if(!name){
document.getElementById('nameError').innerHTML = " ** Empty ! ";
return false;
}
}
<form action="#" onsubmit="return validation()" >
<br>
<label>Name </label>
<br>
<input type="text" name="name" id="name" placeholder="Your name">
<br>
<span id="nameError"></span>
<br>
<input type="submit" value="ok">
</form>
Thank you very much for your help.