Click here to Skip to main content
15,905,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when ever im going to validate through unhide textbox it is ging to be validate but any 1 of the textbox is hide so the javascript code does not validate it throws error

What I have tried:

function validateAGDBAndSLDB() {
debugger;
var txtVal = (document.getElementById("<%=txtAGDB1.ClientID%>").style.display = 'none') + (document.getElementById("<%=txtAGDB2.ClientID%>").value);
(document.getElementById("<%=txtAGDB3.ClientID%>").value) + (document.getElementById("<%=txtAGDB4.ClientID%>").value);
(document.getElementById("<%=txtAGDB5.ClientID%>").value) + (document.getElementById("<%=txtAGDB6.ClientID%>").value);
(document.getElementById("<%=txtAGDB7.ClientID%>").value) + (document.getElementById("<%=txtAGDB8.ClientID%>").value);
(document.getElementById("<%=txtAGDB9.ClientID%>").value) + (document.getElementById("<%=txtAGDB10.ClientID%>").value);
(document.getElementById("<%=txtSLDB.ClientID%>").value) + (document.getElementById("<%=txtSLDB2.ClientID%>").value);
(document.getElementById("<%=txtSLDB3.ClientID%>").value) + (document.getElementById("<%=txtSLDB4.ClientID%>").value);
(document.getElementById("<%=txtSLDB5.ClientID%>").value) + (document.getElementById("<%=txtSLDB6.ClientID%>").value);
(document.getElementById("<%=txtSLDB7.ClientID%>").value) + (document.getElementById("<%=txtSLDB8.ClientID%>").value);
(document.getElementById("<%=txtSLDB9.ClientID%>").value) + (document.getElementById("<%=txtSLDB10.ClientID%>").value);
if (txtVal >= 1 && txtVal <= 240) {
return true;
}
else
alert('Value must be in between 1 to 240');
return false;
}
Posted
Comments
Patrice T 20-Aug-18 0:32am    
Just trow correction matching the error
Shahbaz435 20-Aug-18 1:27am    
the error is cannot foind the value of null if the textbox is hide and if textbox is showing it will be validated
Patrice T 20-Aug-18 1:32am    
Show exact error message !
Use Improve question to update your question.
So that everyone can pay attention to this information.
Shahbaz435 20-Aug-18 1:43am    
cannot find the null value on textbox id in javascript.

If my textbox is hide then throwing the above error.

& if my textbox is not hide then it will be validated but i want is that if my textbox is hide then it will be validate plz help im new in this
ZurdoDev 20-Aug-18 10:19am    
If it is hidden, then no it will not have an error. What you are probably doing is setting .Visible = false in C# and in that case, yes it will error because the control will not be in the HTML at all.

If you use jquery it will work with no error. $("#id").val()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900