Administrators Nathan Posted July 16, 2014 Administrators Share Posted July 16, 2014 I'm trying to figure out the best way to make sure that the word "delete" was entered into this form field on submit. If not then it stops and returns something like "you didn't enter the word delete". <!-- Delete Property Modal --> <div class="modal fade" id="deletepropertyModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title" id="myModalLabel">Remove Property</h4> </div> <div class="modal-body"> <p>Are you sure you want to delete this property? If so type the word "delete" in the box below.</p> <form role="form"> <div class="form-group"> <input type="text" class="form-control" id="delete" required> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary">Delete Property</button> </div> </form> </div> </div> </div> </div> Quote Link to comment Share on other sites More sharing options...
Administrators Nathan Posted July 16, 2014 Author Administrators Share Posted July 16, 2014 Had to add a onsubmit check. function validate() { if (document.getElementById('delete').innerText != 'delete') { alert("you didn't enter the word delete"); return false; } return true; } Quote Link to comment Share on other sites More sharing options...
Kaushik Posted December 2, 2018 Share Posted December 2, 2018 I think you need to close the Input header. Also delete can be all CAPS or only the first D can be caps or all in normal format. Make sure you add all the three variations into your code. Or you can just mention type "delete" as it shown in the text here so that people will understand better. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.