Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: ArturoRobles

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.
User avatar
By ebryant
I'm trying to limit (control) users who can utilize a submit button by inserting a code number:

form = getFormById("9266651675dcc61127194f5057208399");
if ($("#Num").getValue().search(/AD-2019[74-9]0[A-Z]/i) == -1)) {
alert("STOP...Incorrect value.");
return false; //stop submit

I would like to utilize a list of unique acceptable numbers like (AD-201970A, AD-201956B, etc...).
User avatar
By RicardoMG

So you can control the submit button by inserting a code number, I did the following example.
I created a case where I have only one task, likewise i created 3 variables: name: string, email: string and code: string.
In the form I have the following code using JavaScript:
Code: Select all
    var name = $("#code").getValue() 
    var re = new RegExp("^[AD]{2}-[2019]{4}[0-9]{2}[A-Z]$");
    if (re.test(name)) {
       return true; //continue submit
    } else {
       alert("your code is wrong, you can not send the form until you enter the correct code");
       return false; //stop submit
so in this JavaScript code valid using regular expressions that the value in the code variable has the structure as you want (AD-201970A, AD-201956B, etc.), for this I did a video of how it works and i attached it to the comment.
I hope this little development helps you.

Best regards, Ricardo.
(21 MiB) Downloaded 77 times

Any ideas in this regard? Thanks

Can anyone help me please??????

rabbidwombat, I have created a better code examp[…]

Processmaker 3.6.1 OpenSource?

Generally, they share the latest release source co[…]