jeudi 26 mai 2016

In Java web development, how do you allow a form submit to ignore the "required" attribute?

I am using Java with the Spring Web MVC framework to set up a site. I have a form:

<form:form method="post" action="exman/action" modelAttribute="exmanModel">
    <fieldset>
        <form:label path="name">Name</form:label>
        <form:input path="name" type="text" required="required"/>
    </fieldset>
    <button type="submit" class="bt_submit" name="action" value="clear">Clear</button>
    <button type="submit" class="bt_submit" name="action" value="add">Add Entry</button>
    <button type="submit" class="bt_submit" name="action" value="search">Search</button>
</form:form>

When the user clicks Add Entry, they must enter all required fields. However, when the user clicks Clear or Search, no fields should be required. How can I do this?




Aucun commentaire:

Enregistrer un commentaire