Make sure visitor name is not empty in prechat survey

This commit is contained in:
Dmitriy Simushev 2015-05-08 14:54:53 +00:00
parent 5628f42782
commit 5d13afd8f6

View File

@ -61,6 +61,18 @@
* @param Object attributes Attributes hash for test
*/
validate: function(attributes) {
// Check visitor's name
if (this.get('canChangeName') && typeof attributes.name != 'undefined') {
var trimmedName = attributes.name
// Remove leading spaces from the name
.replace(/^\s+/, '')
// Remove trailing spaces from the name
.replace(/\s+$/, '');
if (trimmedName.length === 0) {
return Mibew.Localization.trans('Name is required.');
}
}
// Check email
if (this.get('showEmail')) {
if (typeof attributes.email != 'undefined') {