Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Input type Telephone
-
- Posts: 315
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 87 times
- Been thanked: 11 times
Input type Telephone
Hello,
I would like to use Input Type Telephone. Could you please to point me to the right direction (documentation) or example of use. Idem for Email, Url and others. I am selecting them but no effect, it works like a text field.
Many thx
Yves
I would like to use Input Type Telephone. Could you please to point me to the right direction (documentation) or example of use. Idem for Email, Url and others. I am selecting them but no effect, it works like a text field.
Many thx
Yves
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Input type Telephone
E.g. for Type "Telephone", define attributes like
Next, add a validation in the form's Custom Code:
}
Code: Select all
pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}",placeholder="Format: 123-456-7890"
Next, add a validation in the form's Custom Code:
Code: Select all
function nuBeforeSave() {
const myPhone = document.getElementById('my_phone'); // !! replace my_phone with your object id !!
if (myPhone.validity.patternMismatch) {
nuMessage('Please enter a valid phone number.');
// Cancel saving
return false;
}
// Continue Saving
return true;
You do not have the required permissions to view the files attached to this post.
-
- Posts: 315
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 87 times
- Been thanked: 11 times
Re: Input type Telephone
Hello Kev1n,
It works perfectly with Telephone following your step by step method.
Trying with the same approach for Type = "Email" taking the same approach ie, define attributes like
Putting that on Attributes like you did for Telephone type and add a validation in the nuBeforeSave function on the form's Custom Code.
It sounds that the regular expression is misinterpreted by nubuilder. Any help appreciated as the fields after email aren't rendered..
Yves
It works perfectly with Telephone following your step by step method.
Trying with the same approach for Type = "Email" taking the same approach ie, define attributes like
Code: Select all
pattern="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$",placeholder="Format: mon.compte@mondomain.com"
Code: Select all
function nuBeforeSave() {
const myEmail = document.getElementById('my_email');
if (myEmail.validity.patternMismatch) {
nuMessage('Please enter a valid email.');
// Cancel saving
return false;
}
// Continue Saving
return true;
}
Yves
Re: Input type Telephone
How exactly pattern works? If I wrote the pattern you pointed for email in attributes of my input like this...kev1n wrote: ↑Sun Dec 31, 2023 3:04 pm Try the email pattern from this site:
https://www.w3schools.com/tags/att_input_pattern.asp
Code: Select all
pattern="[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}$"
Code: Select all
Uncaught DOMException: String contains an invalid character
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Input type Telephone
This looks like a parser error. Add the pattern via JavaScript, in the form's custom code:
Code: Select all
$('#your_object_id_here').attr('pattern', '[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,}$');
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Input type Telephone
PS: This has been fixed on Github, so you can set the attribute without JavaScript.