I have a ordinary button:
<button value="finish_with_send" class="finish_with_send">Send</button>
I need to validate two fields before submission, so i have replaced this button with following:
<a href="javascrtip:void(0)" class="finish_with_send">Send</a>
And the validation:
$(".finish_with_send").click(function() {
if(!$("#feedback_string").val() || !$("#feedback_title_string").val()) {
// Validation failed, do something
} else {
// Validation suceeded, submit
}
})
The problem is that i need to submit as done with the previous button where the value came along to recognize submission type:
value="finish_with_send"
Is there a way that to do this again with jQuery?
Keep your
<button>(or go for<input type="submit">which I would recommend for greater browser support)… change your javascript like so:And allow your button to
submitthe form like so:event.preventDefault()stops the default action of an event firing, in the case of a<button type="submit">it’s default action is to submit the form.Working example: http://jsfiddle.net/JUSsf/1/