Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,
I write a code for the dynamic text boxes to contain unique value but it is showing error as JavaScript runtime error: Unable to get property 'Value' of undefined or null reference
My code is as follows
JavaScript
for (j = 0; j <= 30; j++) {

             var id = "txt" + j

             var id1 = "txt" + (j + 1)
             var txtbox = document.getElementById(id);
             var txtbox1 = document.getElementById(id1);
             if (txtbox.Value == txtbox1.Value) {
                 alert("Enter unique serial number");
                 return false
             }
Posted
Comments
Peter_in_2780 2-Feb-15 2:46am    
If you only have 30 text boxes, you'll fall off the end. Check for null/undefined values for txtbox and txtbox1.
Thanks7872 2-Feb-15 3:03am    
I suspect you are trying to get textbox's value before its generated. Put debugger before the line you are getting exception,examine the HTML and make sure the element with that id exists at that time.

1 solution

Hi,
Check this link for your reference

http://www.psacake.com/web/je.asp
 
Share this answer
 

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