[spalenque] - #7812 *WIP

This commit is contained in:
santipalenque 2014-12-04 12:10:39 -03:00 committed by Sebastian Marcet
parent 80b440be52
commit 6e72a65c5b
2 changed files with 17 additions and 12 deletions

View File

@ -233,6 +233,7 @@ class EditProfileForm extends SafeXSSForm {
if($Gender != 'Male' && $Gender != 'Female' && $Gender != 'Prefer not to say'){ if($Gender != 'Male' && $Gender != 'Female' && $Gender != 'Prefer not to say'){
$this->fields->dataFieldByName('GenderSpecify')->setValue($Gender); $this->fields->dataFieldByName('GenderSpecify')->setValue($Gender);
$this->fields->dataFieldByName('GenderSpecify')->removeExtraClass('hide');
} }
} }

View File

@ -40,6 +40,16 @@ jQuery(document).ready(function($) {
return count >0; return count >0;
},'You must add at least one Affiliation.'); },'You must add at least one Affiliation.');
jQuery.validator.addMethod('checkGender', function(value, element,params) {
var gender = $("input[name='Gender']:checked").val();
if (gender) {
if (gender == 'Specify') {
return ($.trim($("input[name='GenderSpecify']").val()) != '');
}
} else {
return false;
}
},'Please specify your gender.');
jQuery.validator.addMethod( jQuery.validator.addMethod(
"regex", "regex",
@ -77,7 +87,7 @@ jQuery(document).ready(function($) {
State:{required: true}, State:{required: true},
Postcode:{required: true}, Postcode:{required: true},
'Affiliations':{checkAffiliations:true}, 'Affiliations':{checkAffiliations:true},
'Gender':{required:true} 'Gender':{checkGender:true}
}, },
messages: { messages: {
FirstName:{ FirstName:{
@ -99,8 +109,7 @@ jQuery(document).ready(function($) {
email:'Primary Email Address is not valid.' email:'Primary Email Address is not valid.'
}, },
SecondEmail:'Second Email Address is not valid.', SecondEmail:'Second Email Address is not valid.',
ThirdEmail:'Third Email Address is not valid.', ThirdEmail:'Third Email Address is not valid.'
Gender:'Please specify your gender'
} }
}); });
@ -139,6 +148,9 @@ jQuery(document).ready(function($) {
} }
}); });
GenderSpecify.on('change',function(){
$("label.error[for='Gender']").remove();
});
var state_input = $(form_id + ' input[name="State"]'); var state_input = $(form_id + ' input[name="State"]');
@ -188,12 +200,6 @@ jQuery(document).ready(function($) {
if(edit_speaker_profile_form.length > 0){ if(edit_speaker_profile_form.length > 0){
//custom validation //custom validation
jQuery.validator.addMethod('checkAffiliations', function(value, element,params) {
var count = $("#AffiliationEditForm_AffiliationEditForm").affiliations('count');
return count >0;
},'You must add at least one Affiliation.');
jQuery.validator.addMethod( jQuery.validator.addMethod(
"regex", "regex",
function(value, element, regexp) { function(value, element, regexp) {
@ -209,10 +215,8 @@ jQuery(document).ready(function($) {
invalidHandler: function(form, validator) { invalidHandler: function(form, validator) {
var errors = validator.numberOfInvalids(); var errors = validator.numberOfInvalids();
if (errors) { if (errors) {
var element = validator.errorList[0].element;
var offset = (element.name == 'Affiliations') ? $(element).prev().offset().top : $(element).offset().top;
$('html, body').animate({ $('html, body').animate({
scrollTop: offset-100 scrollTop: validator.errorList[0].element.offset().top-100
}, 2000); }, 2000);
} }
}, },