I use the HTML5 attribute 'pattern' with 'required' to check the input fields. The required HTML5 attribute works, but it can accept spaces and tabs, which is not very good, because the user will just put spaces. I need a regular expression so that it takes up space and tabs, but can only take characters into account. An example of "ronny jones" should give 10.
In javascript we do this using something like this, I am looking for a similar thing in HTML5
var name = document.forms['contact']['name'].value.replace(/ /g,"");
if(name.length<6){
document.getElementById('message').innerHTML="Enter correct Name";
return false;
}
I found one related question on SO: Is there a minimum length validation attribute in HTML5? but it accepts spaces and tabs that I don't want.
Below is my code with HTML5 template,
<input type="text" name="name" class="form-control" placeholder="Your Full Name" pattern="[A-Za-z]{6,}" title="Name should have atleast 6 characters." required="" />