Created
January 7, 2016 09:18
-
-
Save msonowal/fd6307ae72f94028c315 to your computer and use it in GitHub Desktop.
Jquery validator overrides and defaults to properly display against materialize inputs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CSS | |
label.invalid { | |
color: red; | |
font-size: 0.8rem; | |
left: 0; | |
position: relative; | |
top: -15px; | |
transform: none !important; | |
} | |
JS | |
$.validator.setDefaults({ | |
onkeyup: false, | |
errorClass: 'invalid', | |
validClass: 'valid', | |
submitHandler: function(form) { | |
$(form).find("input[type='submit']").prop('disabled', true); | |
$(form).find("button[type='submit']").addClass("disabled"); | |
$(form).find("button[type='submit']").prop('disabled', true); | |
form.submit(); | |
}, | |
errorPlacement: function(error, element) { | |
error.insertAfter($(element).siblings('label')); | |
} | |
}); | |
$(document).ready(function(){ | |
// Elk formulier met class validate, validatie uitvoeren | |
$("form[class~='validate']").each(function(){ | |
$(this).validate(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment