Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- $('#register')
- .bootstrapValidator({
- message: 'This value is not valid',
- feedbackIcons: {
- valid: 'glyphicon glyphicon-ok',
- invalid: 'glyphicon glyphicon-remove',
- validating: 'glyphicon glyphicon-refresh'
- },
- fields: {
- firstName: {
- validators: {
- notEmpty: {
- message: 'firstName tidak boleh kosong'
- }
- }
- },
- lastName: {
- validators: {
- notEmpty: {
- message: 'The last name is tidak boleh kosong'
- }
- }
- },
- username: {
- message: 'Username tidak sah',
- validators: {
- notEmpty: {
- message: 'The username is required and cannot be empty'
- },
- stringLength: {
- min: 6,
- max: 30,
- message: 'Username minimal 6 karakter atau lebih'
- },
- regexp: {
- regexp: /^[a-zA-Z0-9_\.]+$/,
- message: 'Username tidak boleh mengandung alphabetic dan angka,imputkan huruf'
- },
- // remote: {
- // url: 'remote.php',
- // message: 'The username is not available'
- // },
- different: {
- field: 'password',
- message: 'The username and password cannot be the same as each other'
- }
- }
- },
- email: {
- validators: {
- emailAddress: {
- message: 'Email tidak sah'
- }
- }
- },
- password: {
- validators: {
- notEmpty: {
- message: 'Password tidak boleh kosong'
- },
- identical: {
- field: 'confirmPassword',
- message: 'The password and its confirm are not the same'
- },
- different: {
- field: 'username',
- message: 'The password cannot be the same as username'
- }
- }
- },
- confirmPassword: {
- validators: {
- notEmpty: {
- message: 'The confirm password is required and cannot be empty'
- },
- identical: {
- field: 'password',
- message: 'The password and its confirm are not the same'
- },
- different: {
- field: 'username',
- message: 'The password cannot be the same as username'
- }
- }
- },
- gender: {
- validators: {
- notEmpty: {
- message: 'The gender is required'
- }
- }
- },
- 'languages[]': {
- validators: {
- notEmpty: {
- message: 'Please specify at least one language you can speak'
- }
- }
- },
- 'programs[]': {
- validators: {
- choice: {
- min: 2,
- max: 4,
- message: 'Please choose 2 - 4 programming languages you are good at'
- }
- }
- }
- }
- })
- .on('error.form.bv', function(e) {
- console.log('error.form.bv');
- // You can get the form instance and then access API
- var $form = $(e.target);
- console.log($form.data('bootstrapValidator').getInvalidFields());
- // If you want to prevent the default handler (bootstrapValidator._onError(e))
- // e.preventDefault();
- })
- .on('success.form.bv', function(e) {
- console.log('success.form.bv');
- // If you want to prevent the default handler (bootstrapValidator._onSuccess(e))
- // e.preventDefault();
- })
- .on('error.field.bv', function(e, data) {
- console.log('error.field.bv -->', data);
- })
- .on('success.field.bv', function(e, data) {
- console.log('success.field.bv -->', data);
- })
- .on('status.field.bv', function(e, data) {
- // I don't want to add has-success class to valid field container
- data.element.parents('.form-group').removeClass('has-success');
- // I want to enable the submit button all the time
- data.bv.disableSubmitButtons(false);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement