Page 1 of 1

text input validation

Posted: Wed Jun 09, 2021 1:25 am
by alisoroush7
hello guys
i have a textbox that is named Price. i want a javacode to not allow pepople entering anything except numbers in that field. for example if they enter a text, a pop up message appear and until they correct it , they can not submit the form.

Re: text input validation

Posted: Wed Jun 09, 2021 2:41 am
by kirkwg
Hi,
Why not dynaform > textbox > property > to set validate; no JS coding is needed.
Choose one option below to set the Validate:
    Only integers: ^\d+$
    Only positive or negative integers: ^[\-+]?\d+$
    Integers or decimal numbers: ^[\-+]?\d*\.?\d*$
    Number with up to two decimal digits: ^[\-+]?\d*(\.\d{0,2})?$
    Number with exactly two decimal digits: ^[\-+]?\d*\.\d{2}$
doc FYI: https://wiki.processmaker.com/3.0/Text_and_Textarea_Controls#Example_Regular_Expressions

Re: text input validation

Posted: Thu Oct 26, 2023 5:10 am
by jarrett01
Java code to not allow people entering anything except numbers in a textbox named "Price":

Java
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
https://geometrydash-lite.com
public class NumberOnlyTextField extends JTextField {

public NumberOnlyTextField() {
addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if (!Character.isDigit(e.getKeyChar()) && e.getKeyChar() != KeyEvent.VK_BACK_SPACE) {
e.consume();
JOptionPane.showMessageDialog(null, "Only numbers allowed!");
}
}
});
}
}

Re: text input validation

Posted: Thu Nov 02, 2023 12:00 am
by evawillms
To set the validation for a textbox in ProcessMaker without using JavaScript coding, you can follow these steps:
1. Open the Dynaform designer.https://run3online.pro
2. Select the textbox control for which you want to set the validation.
3. In the properties panel on the left side, locate the "Validate" property.
4. Click on the property value field to open the dropdown menu.
5. From the dropdown menu, select one of the provided options to set the validation pattern.
If you want to set the textbox to allow only integers, you can select the option "Only integers: ^\d+$" from the dropdown menu.