I have a form with 5 input fields (4 text input, 1 checkbox) and I have written this code to handle missing information in the input fields. The code works fine but but it seems repetitive and inefficient. Is there a simpler way to write this code?

```
$("#main-form").on('submit', function(event) {

if (!$("#field1").val()) {
event.preventDefault();
$("#field1-error").html("Error!");
}
else
$("#field1-error").html("");

if (!$("#field2").val()) {
event.preventDefault();
$("#field2-error").html("Error");
}
else
$("#field2-error").html("");

if (!$("#field3").val()) {
event.preventDefault();
$("#field3-error").html("Error");
}
else
$("#field3").html("");

if (!$("#field4").val() && !$("#checkbox1").prop('checked')) {
event.preventDefault();                                       
$("#field4-error").html("Error");
}
else
$("#field4-error").html("");

});

```