Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. //Basic form validation
  2. $('form[novalidate]').on('submit', function(event){
  3. $('.form-control', this).each(function(){
  4. if (this.checkValidity() == false || ($(this).attr('data-match') && $(this).val() != $('#' + $(this).attr('data-match')).val())) {
  5. event.preventDefault();
  6. event.stopPropagation();
  7. $(this).parents('.form-group').addClass('has-error');
  8. }
  9. else {
  10. $(this).parents('.form-group').removeClass('has-error');
  11. }
  12. });
  13. });
  14.  
  15. //Dirty input
  16. $('.form-control').on('focusout', function(){
  17. if (this.checkValidity() != false) {
  18. $(this).parents('.form-group').removeClass('has-error');
  19. }
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement