I want to validate ajaxToolkit combobox via RequiredFieldValidator or Custome Javascript.
RequiredFieldValidator not getting fired.....so i use following javascript for validation.
I dont know is the correct way to do this or any other better option available.
var _ddlPreDepartment=document.getElementById('<%=ddlPreDepartment.ClientID %>');
if (_ddlPreDepartment != null && _ddlPreDepartment != 'undefined' && _ddlPreDepartment.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0].value.toLowerCase() == "select") {
alert('Please select Department.');
_ddlPreDepartment.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0].focus();
return false;
}
Comments: Workaround found, see comments.
RequiredFieldValidator not getting fired.....so i use following javascript for validation.
I dont know is the correct way to do this or any other better option available.
var _ddlPreDepartment=document.getElementById('<%=ddlPreDepartment.ClientID %>');
if (_ddlPreDepartment != null && _ddlPreDepartment != 'undefined' && _ddlPreDepartment.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0].value.toLowerCase() == "select") {
alert('Please select Department.');
_ddlPreDepartment.childNodes[0].childNodes[0].childNodes[0].childNodes[0].childNodes[0].focus();
return false;
}
Comments: Workaround found, see comments.