Adding custom validation to form fields

Hi, i’m facing this issue when i run my code below:

  window.ub.form.customValidators.validacao_telefone = {
    isValid: function(value) {

    message: 'Informe um telefone válido',

“TypeError: window.ub.form is undefined”

My page:

Hey @Eline_M !

Did you find a solution to your problem ?

Hi @Mark_Wainwright, is it possible to get the email validation script to also validate that the entry includes a “domain extension”? With the current script you can submit emails without .com or similar - in other words invalid emails.

1 Like

yes, that would be a good idea.
i still regularly get emails without domain extension

1 Like

I’ve already put in feature requests on solving this… problem is that it’s a valid email without the domain… e.g. test@localhost or employee@companyintranet . so by using html5 email validation these are technically correct although completely useless for a internet only system.

Our solution goes something like:
document.getElementById('email_field_id').setAttribute("pattern", "[a-zA-Z0-9.-_]{1,}@[a-zA-Z0-9.-]{1,}[.]{1}[a-zA-Z0-9]{2,}");

Drop the above into a script and change email_field_id to the id of the email field on your form.

This uses html5 regex pattern matching to use as validation for valid emails (with domain) :wink:

HEllo, Can you send me page file with validate postall code. It will be helpful.
Thank you sir.