I'm using cakephp framework and I'm running into problem if the
element name if different from the element ID.  Currently the form is
getting submitted w/o being validated, but if I change the textarea
name to "contact_description" then it will validate it.  Also I would
like to make sure that atleast 1 checkbox has been selected but i'm
not sure how to add a custom function to multiple checkbox.

<form action="/" method="post" id="sendmessage">
<label for="contact_description">Send a message to project team</
label>
<div id="errorMessageBox">
<label for="contact_description" class="error">Please enter a message</
label>
<label for="developers" class="error">Please select a developer</
label>
</div>
<textarea id="contact_description" name="data[Project]
[contact_description]" class="text"></textarea>
<label for="developers">Select developers.</label>
<table>
<tbody>
<tr>
<td><input class="checkbox" id="contact1" "type="checkbox"
value="email1" name="data[Projects][contact][]"/>Person1</td>
<td><input class="checkbox" id="contact2" type="checkbox"
value="email2" name="data[Projects][contact][]"/>Person2</td>
</tr>
</tbody>
</table>
<button type="submit" class="custom_button" value="Send a
message"><img src="/img/btn_send_a_message.gif" alt="Send a message" /
></button>
</form>

var container = $("#errorMessageBox");
$("#sendmessage").validate({
errorContainer: container,
errorLabelContainer: $("div", container),
event: "keyup",
rules: {
        contact_description: {
                 required: true
         }
}
});

Reply via email to