sutty/app/assets/javascripts/validation.js

32 lines
831 B
JavaScript
Raw Normal View History

2018-06-15 22:13:18 +00:00
$(document).on('turbolinks:load', function() {
$(document).on('keypress', '.post :input:not(textarea):not([type=submit])', function(e) {
2018-06-25 20:36:10 +00:00
if (e.keyCode == 13) {
e.preventDefault();
e.stopPropagation();
}
});
2018-07-23 14:26:40 +00:00
$('.submit-post').click(function(e) {
2018-06-15 22:13:18 +00:00
var form = $(this).parents('form.form');
var invalid_help = $('.invalid_help');
var sending_help = $('.sending_help');
invalid_help.addClass('d-none');
sending_help.addClass('d-none');
2018-06-15 22:13:18 +00:00
if (form[0].checkValidity() === false) {
e.preventDefault();
e.stopPropagation();
invalid_help.removeClass('d-none');
} else {
sending_help.removeClass('d-none');
2018-06-15 22:13:18 +00:00
}
form.addClass('was-validated');
});
2018-12-14 15:12:17 +00:00
$('.submit-post-incomplete').click(function(e) {
$('.sending_help').removeClass('d-none');
});
2018-06-15 22:13:18 +00:00
});