I have this JS inherited maxlength function checker in an ASP page. I'm trying to modify it so when the session("programid")= 30 max_text_length = 6000;
I put an if statement in that looks like this
if (session("programid") == '30'){
max_text_length = 6000;
}
but I keep getting and generic error. "Object expected"
on a line number way below the function.
The code below is the working original statement.
Code:
function MaxLengthChecker(e) {
// max length field checker
var max_text_length = 4000;
var counted_chars = 0;
var src_element = e.srcElement? e.srcElement : e.target;
if (src_element != null) {
if (src_element.value.length > max_text_length) {
src_element.value = src_element.value.substring(0, max_text_length);
window.alert('Maximum Character Length Reached.');
counted_chars = max_text_length;
}
else
counted_chars = max_text_length - src_element.value.length;
if (src_element.type == 'textarea' && src_element.name != 'cpd7' ) {
popup(counted_chars + ' Characters Left');
}
if (src_element.type == 'textbox') {
popup(counted_chars + ' Characters Left');
}
return true;
} else {
return false;
}
}