jeudi 26 mars 2015

Using HTML5 required on Javascript Form Submit

i've a form with a submit button that after the click goes disabled for avoid double insert. Now i've a problem, with the jquery $("#element").submit() the browser doesn't process the required fields in the form. Here my code:



<form ...>
<input type='text' name='element' required/>
<button onClick='disable_btn();' id='submitbtn' type="submit"
class="btn btn-info btn-md col-md-3"> SAVE </button>
</form>

<script>
function disable_btn(nometag)
{$("#submitbtn").html('Saving...');
$("#submitbtn").attr("disabled", "disabled");
$("#submitbtn").closest("form").submit() }
</script>


it works fine with <input type='submit'>


How can i validate (not empty field check) the form? thanks


Aucun commentaire:

Enregistrer un commentaire