my statements and code work well, ALTHOUGH if i click in either textfield and don't enter a value the jQuery registers it as "not empty" in the field and does not execute the alert.
What do you think i've missed? or need to add?
I'm working in a Groovy/Grails environment, hence my g: fields.
// if textfield has or has no content show message
$("#newEdiSaveButton").click(function(){
if (($(".addEdiNumberField").val() != '') && ($(".addEdiDescriptionField").val() != '')) {
return confirm("Please double check your number and description. Once saved you can not delete this combination.");
}
else if (($(".addEdiNumberField").val() == '') && ($(".addEdiDescriptionField").val() == '')) {
alert ("You must enter an EDI # and description before saving.");
}
else if (($(".addEdiNumberField").val() == '')) {
alert ("Please enter an EDI #.");
}
else if (($(".addEdiDescriptionField").val() == '')) {
alert ("Please enter an EDI description.");
}
});
<p id="addNewEDIInfoContainer" style="display:none;">
<g:checkBox name="myCheckbox" value="" />
<g:textField id="" name="myField" value=""
class="addEdiNumberField text shortField"
onfocus="this.className='shortFieldFocus bold'"
onblur="this.className='text shortField'" />
<g:textField id="" name="myField" value="" style="width:350px;"
class="addEdiDescriptionField text"
onfocus="this.className='focus bold'"
onblur="this.className='text'" />
<input id="newEdiSaveButton" type="button" class="button" value="Save" />
</p>