function before_submit_check_if_has_blank_field() {
$("[type=submit]").click(function(e) {
var of_key_field = $('.key_field')
var of_val_field = $('.val_field')
var should_run = 1
if (of_key_field.length === 1) {
$('.key_field:not(:first)').filter(function() {
if (this.value === "") {
alert('Please Fill In Or Remove The Blank Fields First')
e.preventDefault();
should_run = 0
}
});
} else {
$('.key_field').filter(function() {
if (this.value === "") {
alert('Please Fill In Or Remove The Blank Fields First')
e.preventDefault();
should_run = 0
}
});
}
if (should_run != 0) {
if (of_val_field.length === 1) {
$('.val_field:not(:first)').filter(function() {
if (this.value === "") {
alert('Please Fill In Or Remove The Blank Fields First')
e.preventDefault();
should_run = 0
}
});
} else {
$('.val_field').filter(function() {
if (this.value === "") {
alert('Please Fill In Or Remove The Blank Fields First')
e.preventDefault();
should_run = 0
}
});
}
}
update_config_field_from_key_value_field()
});
}
}
The above code snippet is a part of my jquery where I am displaying a layout to the user with some fields and once those fields are empty then I am showing alert message while saving the form.
if (this.value === "") {
alert('Please Fill In Or Remove The Blank Fields First')
e.preventDefault();
should_run = 0
}
if (this.value === "") { alert('Please Fill In Or Remove The Blank Fields First') e.preventDefault(); should_run = 0 }