Validation of invisible textbox

Former Member
Former Member
I have a textbox which gets the value of the select option from a dropdownlist, the textbox is binded to a property of the ItemType which has the Required set to true.  So if no selection is made from the dropdownlist, it will trigger the validation for the required field upon save. However it works (textbox has the value selected, no validation message pops up) when the textbox is visible. But it doesn't seem to work if I change it to invisible, as ideally the textbox should be hidden, the required validation message always pops up even when a selection has been made from the dropdownlist. Please advise if this is possible or should I use other ways to achieve this?
Parents
  • Former Member
    Former Member
    Hi Chris, Yes, it is done on the onChange event of a HTML object, see code below: The validation behaviour doesn't seem to be consistent. If I make the textbox from invisible back to visible, the required validation is still triggered, when there is a value in the textbox. <select id="team_list" onchange='setTeamId()'> </select> <script language='Javascript'> function setTeamId() { var select = document.getElementById("team_list"); var selectedString = select.options[select.selectedIndex].value; var cTeamId= document.getElementsByName("team_id"); var c; for (c = 0; c < cTeamId.length; c++) { if (cTeamId[c].type == "text") { cTeamId[c].value = selectedString ; } } } </script>
Reply
  • Former Member
    Former Member
    Hi Chris, Yes, it is done on the onChange event of a HTML object, see code below: The validation behaviour doesn't seem to be consistent. If I make the textbox from invisible back to visible, the required validation is still triggered, when there is a value in the textbox. <select id="team_list" onchange='setTeamId()'> </select> <script language='Javascript'> function setTeamId() { var select = document.getElementById("team_list"); var selectedString = select.options[select.selectedIndex].value; var cTeamId= document.getElementsByName("team_id"); var c; for (c = 0; c < cTeamId.length; c++) { if (cTeamId[c].type == "text") { cTeamId[c].value = selectedString ; } } } </script>
Children
No Data