Forum Discussion

Former_Member's avatar
Former_Member
Accelerator III
8 years ago

Validation of invisible textbox

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?

2 Replies

  • Hello, How are you setting the value of the textbox from the dropdown? Is this being done from an onChange Field Event on the dropdown? If so, could you share the code that you are using to set the value of the textbox? Chris
    Christopher Gillis Aras Labs Software Engineer
  • 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.type == "text") { cTeamId.value = selectedString ; } } } </script>