// Validate on form submission $('#form-1').submit(function(e) { e.preventDefault(); $(this).formvalidate({ failureMessages: true, successMessages: true, messageFailureClass: 'label label-important', messageSuccessClass: 'label label-success', onSuccess: function(form) { alert('Form #1 is valid!'); } }); });
$('#submit-2').click(function(e) { e.preventDefault(); // From the anchor element find the closest form element $(this).closest('form').formvalidate({ failureMessages: true, successMessages: true, messageFailureClass: 'label label-important', messageSuccessClass: 'label label-success', onSuccess: function(form) { alert('Form #2 is valid!'); }, localization: { en: { success: { name: 'Good, you know your name.', age: 'Ahh, {1}, a wise age.', birth_date: 'The year of the tiger!', email: 'We promise not to stalk you.', continent: function(title, value, name, input) { var text = $(':input[name="' + name + '"] option[value="' + value + '"]').text(); return text + ', really? Me too!'; }, 'colors[]': 'O, wow good choices!', why_cool: 'Ya, u got it!', 'like[]': 'Those are my favorite frameworks too.!' }, failure: { email: function(title, value, name, input) { return 'There is no way that email ' + value + ' is valid.'; } } } } }); });