why i am getting runtime error in javascript at
var ClientID = document.getElementById(“ClientIDTextBox”).value;
and my code is:
<script type="text/javascript">
var ClientID = document.getElementById("ClientIDTextBox").value;
if (ClientID == "") {
alert("Please enter ClientID")
}
</script>
please help me
You are likely getting a runtime error because the call
document.getElementByIdis returningnull. The attempt to get the propertyvalueonnullleads to an error.Try the following instead
The root cause though is likely that your javascript is running before the DOM is loaded and hence your element with id
ClientIDTextBoxis not available. Ensure your javascript runs after the DOM is loaded to prevent this problem.