I am doing some validation and can't get my if statement to work. I want to validate fields with a data type and the required attribute. Or if a field is not null?
My if statement:
if (typeof $(this).attr("data-type") != "undefined"
&& typeof $(this).prop("required") != "undefined"
|| typeof $(this).prop("required") === true
|| $(this).val() != "") {
// Doing stuff
}
The HTML input:
<input type="text" name="Consignee" id="text" data-type="text"
placeholder="Consignee" required>
$(":input[required]")