I want to validate my inputs, so the user can just enter letters. The problem is that it just checks one input field but I selected all with :input
code:
$('#formularID').submit(function() {
var allInputs = $(":input").val();
var regex = new RegExp("[a-zA-Z]");
if(regex.test(allInputs))
{
alert("true");
}else
{
alert("false");
return false;
}
});
I appreciate every help I can get!
.each()to cycle through each input element, you are only getting/testing the value of the first one by doing$(":input").val().!and just checked whether the pattern fails. And @Spencer Wieczorek - (I don't know whether I can do that ) I used$(":input").val().each()but then he does just submit the form without checking the value