H
HockeyFan
I've got a dropdownlist that upon user selection, I have a javascript
function that is run. This function, depending upon which selection
from the dropdown, turns one small section visible and enables its
validator, and turns another similar section off and turns off its
validator. I run this function also on page load, so that it'll run
based on current settings from the database. It works fine, except
that if the user changes the selection, then the validator displays
the error message (because the text box is empty). The thing is, I
set CausesValidation to false on the dropdownlist, so I'm not sure why
this is happening.
Any ideas:
function ddlLoanSystem_Changed()
{
var ddlLoanSystem = document.getElementById('ddlLoanSystem');
var valtxtACCustomerNumber =
document.getElementById('rptBorrower_ctl00_valtxtACCustomerNumber');
var valtxtWCCustomerNumber =
document.getElementById('rptBorrower_ctl00_valtxtWCCustomerNumber');
var spanACCustomerNumber =
document.getElementById('rptBorrower_ctl00_spanACCustomerNumber');
var spanWCCustomerNumber =
document.getElementById('rptBorrower_ctl00_spanWCCustomerNumber');
switch(ddlLoanSystem.options[ddlLoanSystem.selectedIndex].value)
{
case 'ALS':
spanWCCustomerNumber.style.display = 'none';
ValidatorEnable(valtxtWCCustomerNumber, false);
spanACCustomerNumber.style.display = '';
ValidatorEnable(valtxtACCustomerNumber, true);
break;
case 'ACBS':
spanWCCustomerNumber.style.display = '';
ValidatorEnable(valtxtWCCustomerNumber, true);
spanACCustomerNumber.style.display = 'none';
ValidatorEnable(valtxtACCustomerNumber, false);
break;
}
}
function that is run. This function, depending upon which selection
from the dropdown, turns one small section visible and enables its
validator, and turns another similar section off and turns off its
validator. I run this function also on page load, so that it'll run
based on current settings from the database. It works fine, except
that if the user changes the selection, then the validator displays
the error message (because the text box is empty). The thing is, I
set CausesValidation to false on the dropdownlist, so I'm not sure why
this is happening.
Any ideas:
function ddlLoanSystem_Changed()
{
var ddlLoanSystem = document.getElementById('ddlLoanSystem');
var valtxtACCustomerNumber =
document.getElementById('rptBorrower_ctl00_valtxtACCustomerNumber');
var valtxtWCCustomerNumber =
document.getElementById('rptBorrower_ctl00_valtxtWCCustomerNumber');
var spanACCustomerNumber =
document.getElementById('rptBorrower_ctl00_spanACCustomerNumber');
var spanWCCustomerNumber =
document.getElementById('rptBorrower_ctl00_spanWCCustomerNumber');
switch(ddlLoanSystem.options[ddlLoanSystem.selectedIndex].value)
{
case 'ALS':
spanWCCustomerNumber.style.display = 'none';
ValidatorEnable(valtxtWCCustomerNumber, false);
spanACCustomerNumber.style.display = '';
ValidatorEnable(valtxtACCustomerNumber, true);
break;
case 'ACBS':
spanWCCustomerNumber.style.display = '';
ValidatorEnable(valtxtWCCustomerNumber, true);
spanACCustomerNumber.style.display = 'none';
ValidatorEnable(valtxtACCustomerNumber, false);
break;
}
}