I made a simple function that depending on the text of the item selected from a dropdownlist, a textbox will change its maxlength property.
function cambiarLength(drop, textbox) {
var option = document.getElementById(drop);
var texto = option.options[option.selectedIndex].text;
var field = document.getElementById(textbox);
if (texto == 'RUC') {
field.maxLength = 3;
}
else {
field.maxLength = 6;
}
};
Codebehind:
TipoDoc.Attributes.Add("onChange", "javascript: cambiarLength(this, txtDoc);");
Error:
0x800a1391 - JavaScript runtime error: 'txtDoc' is undefined