Community > Discussions
40 views
1 replies

check a field with javascript code

hi guys

i've created a form with live form and i have a field that i must check validity of input with a javascript code like this:

function isValidCode(input) {

if (!/^\d{10}$/.test(input)) return false;

const check = +input[9];

const sum = input.split('').slice(0, 9).map((x, i) => +x * (10 - i)).reduce((x, y) => x + y) % 11;

return sum < 2 ? check == sum : check + sum == 11;

}

i created another textbox that get false or true from function and i've tried serveral times for check my field but this code doesn't work in this module

what should I do?

thanks

mohamad delfan mohamad delfan
Published 05/31/2021 06:59
Add Comment
Ashish Pachori

Unfortunatly, It is not possible with Live Forms. You can only evaluate the JavaScript in Live Forms.

replied 06/01/2021 04:33

Last Activity 06/01/2021 04:33