Created
April 16, 2015 21:51
-
-
Save ryantbrown/4f9d9c145e8d9d2b843d to your computer and use it in GitHub Desktop.
Semantic UI - Auto Validation via Data Attrs
This file contains hidden or 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
// form validation loaded from config | |
$('.ui.form').each(function(index){ | |
var config = $(this).data('config'); | |
if(config !== undefined) { | |
$(this).prepend('<div class="ui icon error message" id="form-errors"></div>'); | |
var settings = APP.config.validation; | |
config.split('.').forEach(function(el, i, arr){ | |
settings = settings[el]; | |
}); | |
$('#form-'+settings.id).form( | |
settings.rules, | |
$.extend({}, APP.config.forms.global.options, settings.options) | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment