Can pattern be used to check input against a checksum (eg mod97)?

If I want to build a form in which certain input has to adhere to a specific checksum (eg. mod97), would that be possible using a specific pattern regex and what would that regex be?

Do you intent to validate a IBAN number? Regex is pattern matching, which can’t do mod 97.

Given googling mod 97 gives me a lot about IBAN validation, i feel morally obligated to mention html5 and JS form validation (both of which are client side validation) and can be disabled by the client, you almost always have to use back-end validation.

of course you can use client side validation to reduce server load, but always be aware that front-end validation is not fool proof.

Okay, i think i have given enough warnings now. You can use JavaScript to validate IBAN numbers and checksum mod 97.

there seem to be existing code snippets/libraries:

i am not vouching for the code quality of these projects, use with caution

Thanks! I was just wondering about the extent of pattern checking since the exercise explained the use of pattern checking the length of a credit card number. Usually websites don’t just check the length of the credit card number but also validity based on a checksum.

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.