Following the requirements, I have disabled all validation controls on the page during the PageLoad event on the server side.
When the submit button is clicked, I want to activate the validations and check if the page is valid for submission. If not, then the submission should be blocked.
I have managed to enable all validators as required, but I am facing an issue where they do not seem to validate the page. Even though I have confirmed that they are enabled and functioning correctly through alerts, they still let the page submit without validation.
It seems like there might be something missing in my approach. Perhaps I need to call a validation method or prevent the default behavior of the submit button. Any guidance in this matter would be greatly appreciated.
Below is the script I am currently using:
<script type="text/javascript">
function NextClicked() {
var _ddlStatus = document.getElementById("<%=ddlEmpStatus.ClientID%>");
var _selectedIndex = _ddlStatus.selectedIndex;
if (_selectedIndex == 0) {
alert("Nothing selected");
} else {
if (_selectedIndex == 1) {
for (i = 0; i < Page_Validators.length; i++) {
Page_Validators[i].Enabled = true;
}
}
}
}
</script>