I have a div which contains a text fields for a name and email address. This div disappears if the validation passes but in case of invalid email address I want to show the message without letting the div to disappear. For name validation I am using JS but for email address I am calling a service.
JSP
<form name="resendEsignatureFormId" id="resendEsignatureFormId" action="myStruts2Action "method="POST"/>
<div id="Signers" style="display: none;">
        <s:iterator value="intgDetails.custDetails.signers" var="signerslist">
            <div class="sectionHeaderLine"></div>
            <div class="sectionHeader">Signer #<%=ct%></div>
            <div id="display" class="fieldLabelBold" style="color:red"> 
                <c:if test="${emailValidationMessage != null}">
                    <div class="fieldLabelBold" style="color:red">${emailValidationMessage}</div>
                </c:if>
            </div>
            <table width=100%>                                              
                <tr align="left">
                    <td align="left">
                        <s:textfield name="nameId" id="nameId" label="Name" cssClass="dataFieldCell3" value="%{#signerslist.name}" />
                    </td>
                </tr>
                <tr align="left">
                    <td align="left">
                        <s:textfield name="emailId" id="emailId" label="Email" cssClass="dataFieldCell3" value="%{#signerslist.email}" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <s:textfield name="recipientId" id="recipientId" style="display: none;" value="%{#signerslist.recipientId}" />
                    </td>
                </tr>
                <%
                    ct++;
                %>
            </table>
        </s:iterator>
        <table width=100%>
            <tr>
                <td class="esignNavigation">            
                    <a href="#x" onclick ="return validateEmailAddress()"><span>Confirm</span></a>
                    <a href="#x" onclick="hideSigners()"><span>Cancel</span></a>
                </td>
            </tr>
        </table>
    </div>
JS
function showSigners() {
    $(Signers).show();
}
function hideSigners() {
    if (true == $(Signers).is(':visible')) {
        $(Signers).hide();
    }
} 
function validateEmailAddress() {       
    if( document.getElementById( 'nameId' ).value == "" ) {
        document.getElementById( 'display' ).innerHTML ='Please provide name';
        return false;
    }   
    document.getElementById( 'resendEsignatureFormId' ).submit();
}   
I thought by checking the variable emailValidationMessage for null condition in the function I could reappear the div tag but it is not working.
function validateEmailAddress() {       
    if( document.getElementById( 'nameId' ).value == "" ) {
        document.getElementById( 'display' ).innerHTML ='Please provide name';
        return false;
    } if( '${emailValidationMessage}' != null ) {
        $(Signers).show();
    }   
    document.getElementById( 'resendEsignatureFormId' ).submit();
} 
