javascript - Add more/remove functionality is throwing out of validation -
i trying submit form in have addmore functionality in it.
example: have entered name , have used addmore button remove appeared in second tr. when click remove tr removed now, when click form submit button skipping phone number validation, remove functionality throwing out validation.
my html looks this:
<form> name<input type="text" name="name" id="name" placeholder="name name "/> <table class="skillstable" id="jobskills"> <tbody> <tr class="gdskilltr"> <td><button type="button" class="addskills"> add skill</button></td> <td><button type="button" class="removeskill"> remove skill</button></td> </tr> </tbody> </table> phone<input type="text" name="phone" id="phone" placeholder="enter phone "/> <button type="submit" id="jobsubmit">submit</button> </form> and here javascript validation starts:
var skillcount = 1; $(".addskills").click(function () { $('#jobskills tr:last').after('<tr class="gdskilltr "><td></td></tr>'); skillcount++; }); $("#jobskills").on('click', '.removeskill', function () { $(this).parent().parent().remove(); }); $("#jobsubmit").click(function () { if ($("#name").val() == '') { $("#warning_message").html('please enter name'); $("#name").focus(); return false; } if ($("#phone").val() == '') { $("#warning_message").html('please enter name'); $("#phone").focus(); return false; } }
Comments
Post a Comment