I have a form with 3 inputs of type text. I need on submit of that form to make a validation with required fields. I need the user to complete only two inputs of that form, no mather which one of them, and then submit the form. How would I make this? I don't get the logic here.
My code:
$('#submit-btn').on('click', function(e){
e.preventDefault();
var input1 = $('#input1').val();
var input2 = $('#input2').val();
var input3 = $('#input3').val();
if(input1 == '' || input2 == ''){
alert('you have to complete only 2 fields')
}else{
$('#form').submit();
}
});
<form action='' method='post' id='form'>
<input type='text' value='' name='input1' id='input1'>
<input type='text' value='' name='input2' id='input2'>
<input type='text' value='' name='input3' id='input3'>
<input type='text' value='' id='submit-btn'>
</form>