Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By maabik
#827514
Hello,

Actually, i am using ProcessMaker version “3.3.17 – Enterprise Edition”.

I am using the suggest control to select employees from table "users", and I have a specific requirement where I need to force the selection on this suggestion control.

The option of “Force Selection” is available only on version 3.4 as mentioned on the wiki (https://wiki.processmaker.com/3.2/Suggest_Control#Force_Selection).

Can you please tell me how to implement this functionality on the Dynaform using JAVASCRIPT?

Thank you for help.
Kind Regads.
#827877
Hello!
You can use the following javascript code:
Code: Select all
$("#submit").find("button").click(function(){
	var name = $("#name").getValue() //$("#id-suggest")
	if (name == "") {
    	alert("Name must be filled out");
        return false; //stop submit
	}else{
      	return true; //continue submit
	}
});
Best regards, Ricardo
#828983
Hi!
I tried with this example but the code only validates if the field is not empty, but it doesn´t force the user to select an option from the list. The user can input any text in the suggestion box without restrictions.
Any idea? Thanks!
#828992
Hi,
Force to select using the codes below, please try... (code tested below)
Code: Select all
//--------------- soluntion 1, tested
$( "#" + $("form").prop("id") ).setOnSubmit(function (){

      var name = $("#mySuggest").getValue();
      if (name == "") {
          alert("Name must be filled out");
          //getFieldById("mySuggest").setFocus();	
          return false; //stop submit

      }else{
          var aOptions = $("#mySuggest").getInfo().options; 	//return an array of ["name1", "name2", ...]
          var notMatchCount = 0;
          for (let i in aOptions) {
              if (aOptions[i].value != name) notMatchCount++;
          }
          if (notMatchCount == aOptions.length){
              alert("your customed name is not matched with any of suggested name list?");
              $("#mySuggest").setValue("");	//reset the name field
              //getFieldById("mySuggest").setFocus();		
              return false;   //stop submit the form
          }     
                                   
    }
});

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[…]