Hi all,
How can I detect the field type in LiveCycle Designer ES using JavaScript?
If I have several different fields such as text fields & drop down lists which all have the same function assigned to them on their Enter event such as:
form.section_1.contents.text_field::enter - (JavaScript, client)
functions.detect_field(this);
How do I return the type of field in the function call? I was hoping something like the following would work:
function detect_field(element){
if(element.type == "text"){
return "text field detected";
} else if(element.type == "dropdown"){
return "drop down list detected";
}
}
Any help would be greatly appreciated!
Cheers,
Views
Replies
Total Likes
Use the className property on a node. See the click event on the 'Validate' button on the attached. It iterates over a sub-form and identifies fields by className.
Steve
Views
Replies
Total Likes
className cannot detect field types.
A solution is to resolveNode from the field object, checking for presence of field-type unique tags:
field.resolveNode("value.#text"))
field.resolveNode("ui.#checkButton")
field.resolveNode("ui.#numericEdit")
field.resolveNode("ui.#dateTimeEdit")
field.resolveNode("value.#decimal") && field.resolveNode("value.#decimal").leadDigits
You'll need to add additional tests for dropdowns and so on.
Views
Replies
Total Likes
Or if you develop a naming convention for the fields that will include the type of field then you can interrogate the name of the field and derive what you want. For example:
btnSubmit - for a button
txtHeader - for a text object
fldName - for a field
Paul
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies