JavaScript events triggered on screen via custom script

JavaScript has various event handlers, like onChange or onMouseOver. In HR.Net it is not obvious how things work and how to trigger functions based on events.. Here are some tips:

This is how to trigger event when date field on the screen is changed..

var date = $('#DATEFIELDNAME_txtInput');
date.blur(function() {

Where DATEFIELDNAME is a name of the date field; required_function() is something that you need to run when date is changed. For some reason onChange event did not work properly for me.

Text fields events are not straight forward either.

var text_input = document.getElementById("TEXTFIELDNAME_txtInput"); 
text_input.onblur = function(){ required_function();};
text_input.onchange = function(){required_function();};
text_input.onkeyup = function(){required_function();};

Where TEXTFIELDNAME is a name of the date field.

HR.Net is wrapping every form element into a span-container and you can not trigger events on these containers, hence you need to go directly to HTML the object, hence we are adding “_txtInput” after name of the field name.
Inbuilt function $HRnet(“fieldname”) has a limited use and not always helpful.

Also you can reference fields in JQuery style:

var Date = $('#DATEFIELDNAME_txtInput');
This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

4 Responses to JavaScript events triggered on screen via custom script

Leave a Reply

Your email address will not be published.