I have some input fields, which I want to validate directly as the user is typing
The input fields are bind to certain conditions though.
Here is the example:
<input type="text" data-type="inputFullName" />
<br />
<input type="text" data-type="inputEmail" />
<br />
<input type="text" data-type="inputPhone" />
<br / >
<input type="checkbox" id="chkbox" />
<label>Check here</label>
<br />
<button id="button1" disabled>Click</button>
And the JS:
$('input').on('keyup change', function () {
$('#button1').prop('disabled', $('input[data-type="inputFullName"]').val() == '' || $('input[data-type="inputEmail"]').val() == '' || $('input[data-type="inputPhone"]').val() == '' || !$('input[type="checkbox"]').is(':checked'))
});
So far so good, but how can I check for:
1) user has entered full name (first+lastname)
2) email is actually an email
3) phonenumber is 8 numbers long
I have made an JSFiddle
Any help is appreciated.