Share ideas, ask questions, and get feedback about developing for ProcessMaker
Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
By awisla
#785119
Hello,
How to clear datetime field by javascript:
Simple
$('#var_hourFrom').setValue('');
$('#var_hourFrom').setText('');
does not work as date format is required.

Thank you for help.
Adrian
By Margrate
#787196
Hello Amos,

The given JavaScript code to clear datetime controls is working fine. But when we want to check the mandatory of the same datetime control based on conditions the value still exists at the backend so it is not checking the mandatory of the field.
Please find the attached .json.

Please help us on this.
Attachments
(3.02 KiB) Downloaded 525 times
User avatar
By amosbatto
#787210
The problem is that the selected data is still in the model information for the field and I don't know how to set this. You can use setOnSubmit() to check whether the field is empty and display an alert to the user, like this:
Code: Select all
$("#clearDate").click(function() {
   $("#form\\[eventDate\\]").val('');
   $("#form\\[eventDate_label\\]").val('');
});

getFormById('64428352758068d2fe4eb97051094686').setOnSubmit(function() {
 if ($("#form\\[eventDate\\]").val() == '') {
    alert("Please set an Event Date.");  
    return false; //stop submit
  }
});
Where '64428352758068d2fe4eb97051094686' is the UID of the DynaForm, and eventDate is the ID of the date field and clearDate is the ID of the button to clear the date field.
User avatar
By amosbatto
#787258
I filed a bug report about this, but the developers responded that the fileupload in version 3.1 allows a user to delete selected files. If you only want one file to be uploaded, you can use javascript to limit it with fileupload.
User avatar
By amosbatto
#788356
I found a solution in the JavaScript:
Code: Select all
$("#clearDate").click(function() {
   $("#form\\[dueDate\\]").val('');
   $("#form\\[dueDate_label\\]").val('');
   getFieldById("dueDate").model.attributes.data.label='';
   getFieldById("dueDate").model.attributes.data.value='';
});
where "clearDate" is the ID of the datetime control and "clearDate" is the ID of a button.
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]