0

JSP:

<input type='hidden' 
       id='<bean:write name="academicGoalLevel" property="contentId1" />' 
       name='<bean:write name="academicGoalLevel" property="contentId1" />'
       value='<bean:write name="academicGoalLevel" property="activity1" />' 
  />

JavaScript:

// id is 30 only
var x = document.getElementById('30').value;
alert(x);
if (x.length != 0) {
    alert("Please Enter a School Year 1");
    return false;
}

The first time I go to the page and enter the data in text field I'm not able to get the value in JavaScript.

When I come a second time I get the hidden fields.

How can I resolve this?

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • `IDs` cannot start with or contain only numbers. http://stackoverflow.com/questions/70579/what-are-valid-values-for-the-id-attribute-in-html – W.D. Oct 28 '14 at 11:00
  • Wait for your html to render first before executing javascript code – umair Oct 28 '14 at 11:00

0 Answers0