How would a person go about implenting a validation on a field using the luhnCheck?
function luhnCheck(number) {
number = String(number);
let sum = parseInt(number.charAt(number.length - 1));
for (let i = 0; i < number.length - 1; i++) {
let value = parseInt(number.charAt(i));
if (i % 2 === 0) {
value *= 2;
}
if (value > 9) {
value -= 9;
}
sum += value;
}
return sum % 10 === 0;
}
How to validate a field with the luhnCheck
How to validate a field with the luhnCheck
AwareIM Developer edition. Version 8.5 (Build 2827) running on Windows Server 2012 R2 Standard
Re: How to validate a field with the luhnCheck
You can do this with Custom JS or function (build on Java).
From,
Himanshu Jain
AwareIM Consultant (since version 4.0)
OS: Windows 10.0, Mac
DB: MYSQL, MSSQL
Himanshu Jain
AwareIM Consultant (since version 4.0)
OS: Windows 10.0, Mac
DB: MYSQL, MSSQL
Re: How to validate a field with the luhnCheck
How do a reference the check to the javascript?
AwareIM Developer edition. Version 8.5 (Build 2827) running on Windows Server 2012 R2 Standard
Re: How to validate a field with the luhnCheck
Search the forum for exec_script and you will find many different examples of this in use. If you figure it out, please share the solution as a tip. Thanks
Henrik (V8 Developer Ed. - Windows)
-
- Posts: 1463
- Joined: Tue Jan 24, 2017 5:51 am
- Location: 'Stralya
Re: How to validate a field with the luhnCheck
LuhnCheck is part of the commons validator package. https://commons.apache.org/proper/commo ... Digit.html
That's the good news, the bad news is that the version of commons validator that has been implemented in Aware does not include it.
But! I have implemented elements of commons validator into my own Java plug in so it is super easy to do https://awareim.com/forum/viewtopic.php?f=4&t=11751
IANAJP* and I managed to do it pretty much first time with the aid of the How to YouTube videos
https://youtu.be/-TSpGdb-oWg
https://youtu.be/yGEyyffgoLo
https://youtu.be/RiP845aGzws
* I Am Not A Java Programmer
That's the good news, the bad news is that the version of commons validator that has been implemented in Aware does not include it.
But! I have implemented elements of commons validator into my own Java plug in so it is super easy to do https://awareim.com/forum/viewtopic.php?f=4&t=11751
IANAJP* and I managed to do it pretty much first time with the aid of the How to YouTube videos
https://youtu.be/-TSpGdb-oWg
https://youtu.be/yGEyyffgoLo
https://youtu.be/RiP845aGzws
* I Am Not A Java Programmer
Re: How to validate a field with the luhnCheck
If you need a function built on Java, you can PM me.
From,
Himanshu Jain
AwareIM Consultant (since version 4.0)
OS: Windows 10.0, Mac
DB: MYSQL, MSSQL
Himanshu Jain
AwareIM Consultant (since version 4.0)
OS: Windows 10.0, Mac
DB: MYSQL, MSSQL