I've been trying to solve this problem for some time, but I've been unable to. I have to make a form and I must validate the name input to have at least 3 words in it within JavaScript. I think the best way to do it is with Regex and its \b property.
This is
<input type="text" class="texto" name="Nombre" id="name" title="nombre_cliente" style="color:#888;" placeholder="Nombre del cliente" />
What I mean to do in my JavaScript code is this:
if(document.getElementById("name").value.match(RegExCodeForMin3Words) === null){
alert("Name invalid");
}
So far I've been unable to learn how to make regex match the amount of words (I'm still a beginner at Regex). Can you help me tackle this problem? Maybe Regex isn't the best option available to solve this?
Thanks!