| Server IP : 104.21.37.246 / Your IP : 172.71.28.145 [ Web Server : Apache System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64 User : cp648411 ( 1354) PHP Version : 7.2.34 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home2/cp648411/public_html/kainumber.com/plugin/bootstrapvalidator-master/test/spec/ |
Upload File : |
describe('dynamic fields', function() {
beforeEach(function() {
$([
'<form class="form-horizontal" id="dynamicForm">',
'<div class="form-group">',
'<input type="text" name="fullName" class="form-control" />',
'</div>',
'</form>'
].join('\n')).appendTo('body');
$('#dynamicForm').bootstrapValidator({
fields: {
fullName: {
validators: {
notEmpty: {
message: 'The full name is required and cannot be empty'
},
stringLength: {
min: 8,
max: 40,
message: 'The full name must be more than %s and less than %s characters long'
},
regexp: {
enabled: false,
regexp: /^[a-zA-Z\s]+$/,
message: 'The full name can only consist of alphabetical, number, and space'
}
}
},
// #725: Note that the email field isn't available in the form yet
email: {
validators: {
emailAddress: {
message: 'The email address is not valid'
}
}
}
}
});
this.bv = $('#dynamicForm').data('bootstrapValidator');
this.$fullName = this.bv.getFieldElements('fullName');
});
afterEach(function() {
$('#dynamicForm').bootstrapValidator('destroy').remove();
});
// https://github.com/nghuuphuoc/bootstrapvalidator/pull/725
it('adding field [does not exist but is already set in "fields" option]', function() {
var $div = $('<div/>').addClass('form-group').appendTo($('#dynamicForm'));
$email = $('<input/>')
.attr('type', 'text')
.addClass('form-control')
.attr('name', 'email')
.appendTo($div);
this.bv.addField('email');
this.$fullName.val('Phuoc Nguyen');
$email.val('not valid@email');
this.bv.validate();
expect(this.bv.isValidField('email')).toBeFalsy();
expect(this.bv.isValid()).toBeFalsy();
this.bv.resetForm();
$email.val('[email protected]');
this.bv.validate();
expect(this.bv.isValidField('email')).toBeTruthy();
expect(this.bv.isValid()).toBeTruthy();
});
});