$('#update-form').bootstrapValidator({
trigger: 'blur',
fields: {
first: {
validators: {
notEmpty: {
message: 'Your first name is required'
},
regexp: {
regexp: /^[a-zA-Z ]+$/,
message: 'Your first name cannot have numbers or symbols'
}
}
},
last: {
validators: {
notEmpty: {
message: 'Your last name is required'
},
regexp: {
regexp: /^[a-zA-Z ]+$/,
message: 'Your last name cannot have numbers or symbols'
}
}
},
email: {
validators: {
notEmpty: {
message: 'The email is required'
},
emailAddress: {
message: 'The input is not a valid email address'
}
}
},
phone: {
validators: {
notEmpty: {
message: 'The phone number is required'
},
regexp: {
regexp: /^\+?1?([()/\.\-\s]*[0-9]){10}\s*((ext|x)\s*[0-9]+)*$/,
message: 'The input is not a valid US phone number'
}
}
}
}
})
.on('error.field.bv', '[name="phone"]', function(e, data){
// change the data-bv-trigger value to keydown
$(e.target).attr('data-bv-trigger','keydown');
// destroy the plugin
// console.info(data.bv.getOptions());
data.bv.destroy();
// console.info(data.bv.getOptions());
// initialize the plugin
$('#update-form').bootstrapValidator(data.bv.getOptions());
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.