Hi, I did forms with Wix forms and I am customizing it with codes. I had help to create mask to fields like phone number, cnpj (business code) and cep (postal code), but the code only works with text input type:
// example phone number
function Guid() {
var phone = $w("#input7").value;
var cellphoneGuid = "(" + phone.slice(0, 2) + ") " + phone.slice(2, 7) + " - " + phone.slice(7, 11);
var phoneGuid = "(" + phone.slice(0, 2) + ") " + phone.slice(2, 6) + " - " + phone.slice(6, 10);
if (phone.length === 10) {
$w("#input7").value = phoneGuid;
}
if (phone.length === 11) {
$w("#input7").value = cellphoneGuid;
} else if (phone.length < 10) {
$w("#input7").style.color = "red";
}
}
export function input7_change(event, $w) {
Guid();
}
export function input7_keyPress(event, $w) {
$w("#input7").maxLength = 11;
}
I'm trying make conditions to validate these fields (they are already required). How to prevent a form from being sent if web-user tipe less numbers?? And how do you force the user to enter numbers, if i change the input type, all code doesn't work?