Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By heemalkumar
#815432
Hi Team
I have a dropdown named as dropdown1 which has selections 'Yes' and 'No'
I also have a textbox named as text001

Once a user selects 'Yes' in the dropdown, I was the textbox to be filled in by user. What do i do so it becomes mandatory once a 'Yes' is selected.
User avatar
By amosbatto
#815434
In the properties of your "text001" field, mark its required property. Then, add the following JavaScript to the DynaForm:
Code: Select all
function requireTextField(newVal, oldVal) {
   if (newVal == 'Yes') {
       $("#text001").enableValidation();
   }
   else {
        $("#text001").disableValidation();
   }
}
//execute when the value of the dropdown changes:
$("#dropdown1").setOnchange(requireTextField); 
//execute when the form loads:
requireTextField( $("#dropdown1").getValue(), '' );

See: https://wiki.processmaker.com/3.1/JavaS ... Validation
User avatar
By kirkwg
#829344
Hi there,
Say the textbox at column-2 and dropdown at column-1 are inside the same Grid... your code should look like this below:
Try and let me know, thanks.
Code: Select all
//if the dropdown field e.g. column 1 in the aGrid, the setOnchange() is different, use 'form'.setOnchange() instead
//========== JS disable validation on a particular field inside a grid on a particular row

$( "#" + $("form").prop("id") ).setOnchange( function( fieldId, newValue, oldValue ) {
   var aMatches = fieldId.match(/^\[aGrid_id\]\[(\d+)\]\[dropdown_id\]$/);
  
   if (aMatches) {    
       var rowNo       = aMatches[1];

       if (newValue == 'No') {     	
           getFieldById(aGrid_id).gridtable[rowNo-1][1].disableValidation();     //particular cell textbox on col-2, but index is[1]
       } else 
          getFieldById(aGrid_id).gridtable[rowNo-1][1].enableValidation();     
   }
});
By anavid
#829347
Thanks kirkwg
consider it
I have a grid in which I have some web controls, including one dropdown named as dropdown1 and one text named as text1.
I want the code if you select options 5 and 6 in Drop Down, make the text visible and mandatory, else The text should be disable and hidden.
And do the same in all grid rows
(((/*In fact, we can use this code inside the grid
function requireTextField(newVal, oldVal) {
if (newVal == 'Yes') {
$("#text001").enableValidation();
}
else {
$("#text001").disableValidation();
}
}
//execute when the value of the dropdown changes:
$("#dropdown1").setOnchange(requireTextField);
//execute when the form loads:
requireTextField( $("#dropdown1").getValue(), '' );*/)))

I hope I have made my point clear
Thanks a lot
User avatar
By kirkwg
#829348
Hi Anavid,

As far as I know, we can't hide a particular field inside a grid. We can only hide a whole column.
But you can disable a field I think, Kindly revise your wants?

Reference doc:
https://wiki.processmaker.com/3.1/Grid_Control#JavaScript_Functions
jQuery("#gridId").hideColumn(colIndex)
jQuery("#gridId").showColumn(colIndex)
jQuery("#gridId").disableValidation(colIndex)
jQuery("#gridId").enableValidation(colIndex)

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]