function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TigerPowerTigerPower 

Validating with javascript, possible?

Hey, what do you think... is it possible to validate a field with a s-control (javascript)? I'm now validating SSN field with REGEX, but would like to improve the validation with javascript code.

 

Best Regards,

TP

JakesterJakester
Pretty darn sure it's not possible. Just curious, how would javascript do better validation than RegEx?
TigerPowerTigerPower

Well, here's some background:

In Finland, the personal identification number (Finnish: henkilötunnus (HETU), Swedish: personbeteckning), formerly known as sosiaaliturvatunnus (SOTU) Social Security number) is used for identifying the citizens in many government and civilian systems. It uses the form DDMMYYCZZZQ, where DDMMYY is the date of birth, C is the century identification sign (+ for the 19th century, - for the 20th and A for the 21st), ZZZ is the personal identification number (odd number for males, even number for females) and Q is a checksum character. For example, a valid henkilötunnus is 311280-999J.

The checksum character is calculated thus: Take the birth date and person number, and join them into one 9-digit number x. Let n = x mod 31. Then the checksum letter is the (n+1)th character from this string: "0123456789ABCDEFHJKLMNPRSTUVWXY".

(http://en.wikipedia.org/wiki/National_identification_number#Finland)

 

I'm now validating SSN with REGEX, and also would want to add that checksum character validation to my rule. I also have one working javascript code available (for that checksum calcutations), but I don't know how to modify my REGEX to use it (or use it some other way). The logic is clear though. :smileyhappy:

 

Best Regards,

TP

 

JakesterJakester
Wow! In comparison, our SSN is so simple. Well you could add many layers of validation rules to catch most of these things, maybe all. For example, if you're storing the sex, you could have a validation check for odd/even, and have another validation to check that the MM is between 1 and 12, and so on.
TigerPowerTigerPower

Yes, but the checksum (last character of SSN) is the challenging one. I think that it can't be included to regex validation rule. And that's why I'm wondering what to do with my javascript code...

 

BR,

 

TP

JakesterJakester
Have you tried to write the checksum as a separate validation rule? Seems like it should be doable.