Fairly new to jquery but I realize my code could be condensed. It works just fine but there's got to be a better way to do this as it kind of seems like redundant code. I've got two input fields and a textarea that I'm validating see below. Code samples would be ideal since I'm still learning but any help is appreiacted:
$("form#designForm").submit(function(){
if($("#ccDesignFirstName").val().length == 0){
alert("Full Name field is required");
$("#ccDesignFirstName").focus();
return false;
}
if($(".telephoneInput").is(":visible")){
if($("#ccDesignTelephone").val().length == 0){
alert("Phone is required");
$("#ccDesignTelephone").focus();
return false;
}
}
if($("#ccDesignProblem").val().length == 0){
alert("Question is required");
$("#ccDesignProblem").focus();
return false;
}
});