last name field validation was not working correctly

This commit is contained in:
tworrall 2012-04-25 14:40:24 +00:00
parent 558737bf80
commit 7db46abff9
2 changed files with 73 additions and 1 deletions

View file

@ -0,0 +1,72 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var orgHasPositionUtils = {
onLoad: function(blankSentinel) {
this.sentinel = '';
if ( blankSentinel ) { this.sentinel = blankSentinel; }
this.initObjectReferences();
this.bindEventListeners();
$.extend(this, vitro.customFormUtils);
if ( this.findValidationErrors() ) {
this.resetLastNameLabel();
}
},
initObjectReferences: function() {
this.form = $('#organizationHasPositionHistory');
this.person = $('#person');
this.firstName = $('#firstName');
this.lastName = $('#lastName');
this.personUri = $('#personUri');
// may not need this
this.firstName.attr('disabled', '');
},
bindEventListeners: function() {
this.idCache = {};
this.form.submit(function() {
orgHasPositionUtils.resolvePersonNames();
});
},
resolvePersonNames: function() {
var firstName,
lastName,
name;
// If selecting an existing person, don't submit name fields
if (this.personUri.val() == '' || this.personUri.val() == this.sentinel ) {
firstName = this.firstName.val();
lastName = this.person.val();
name = lastName;
if (firstName) {
name += ', ' + firstName;
}
this.person.val(name);
this.lastName.val(lastName);
}
else {
this.firstName.attr('disabled', 'disabled');
this.lastName.attr('disabled', 'disabled');
}
},
resetLastNameLabel: function() {
var indx = this.person.val().indexOf(", ");
if ( indx != -1 ) {
var temp = this.person.val().substr(0,indx);
this.person.val(temp);
}
}
}

View file

@ -117,7 +117,7 @@ Set this flag on the input acUriReceiver where you would like this behavior to o
<input class="display" type="hidden" acGroupName="person" id="personDisplay" name="personLabelDisplay" value="${personLabelDisplayValue}" >
</p>
<div class="acSelection" acGroupName="person">
<div class="acSelection" id="personAcSelection" acGroupName="person">
<p class="inline">
<label>Selected Person:</label>
<span class="acSelectionInfo"></span>