How to allow entering only numbers and certain characters in a table field :
+
-
=
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Allow only numbers and symbols in a field
-
- nuBuilder Team
- Posts: 4497
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 75 times
- Been thanked: 511 times
- Contact:
Re: Allow only numbers and symbols in a field
Hi,
Do you want the validation to happen in the browser using JavaScript?
Do you want the validation to happen in the browser using JavaScript?
-
- Posts: 370
- Joined: Sat Apr 11, 2020 12:03 am
- Has thanked: 3 times
- Been thanked: 4 times
- Contact:
Re: Allow only numbers and symbols in a field
I would like to have a field restriction on alphabetic characters
-
- nuBuilder Team
- Posts: 4497
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 75 times
- Been thanked: 511 times
- Contact:
Re: Allow only numbers and symbols in a field
alphabetic characters means letters A–Z and a–z, but initially you wrote "only numbers and certain characters".
-
- nuBuilder Team
- Posts: 4497
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 75 times
- Been thanked: 511 times
- Contact:
Re: Allow only numbers and symbols in a field
For example, to allow only digits and the characters +, -, =:
Add an oninput event to your input object and call
In the form’s Custom Code, declare the function:
You can use AI to help modify the regex if you need to allow additional characters or other patterns.
Add an oninput event to your input object and call
validateInput(this);
.In the form’s Custom Code, declare the function:
Code: Select all
function validateInput(input) {
// Allow digits, +, -, =
let regex = /^(\d|[+\-=])*$/;
if (!regex.test(input.value)) {
input.value = input.value.slice(0, -1); // remove last invalid character
}
}