HTML5 and jQuery with jQuery Mobile. I want to use a button to submit a form so that an image can be included in it.
The form needs to be validated, too.
With the following, the form submits but is not validated. That is, if I leave a required form element blank, the form will submit (the alert box shows up).
Any help is appreciated. Thanks!
<form id="myform" name="myform">
[required elements here to validate]
<button type="button" name="submit1" id="submit1"><img src="myimg" />Submit</button>
</form>
....
jQ('#submit1').click(function(event){
jQ('#myform').submit(event);
event.preventDefault();
[more code here to run]
alert('submitted');
});
Aucun commentaire:
Enregistrer un commentaire