I came across a problem where if a field has value already present, it needs to be disabled.
I tried to use Logic with simple JavaScript trigger but I’m not sure when this trigger is evaluated, but the trigger is executed onchange or onblur.
This works but since trigger executes onblur or onchange, as soon as I type some characters the field is disabled.
It should execute only once on form load. I have tried adding a hidden HTML component but calling the onload function is not working.
HTML component code:
<!DOCTYPE html>
<html>
<body onload="myFunction();">
<script>
function myFunction() {
if(document.getElementById('empName').innerHTML.length > 0)
{
document.getElementById('empName').setAttribute('disabled ', 'disabled');
}
}
</script>
</body>
</html>
I'm not very good with JavaScript or have used form.io before. Also, I could not understand how to use Trigger type Event and call it externally. Thanks for the help.


