Semantic UI - Auto Validation via Data Attrs
// 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