Takes a string input and validates it using calculated checksum based on http://www.ngiam.net/NRIC/NRIC_numbers.pdf
Read more on Rollup
<!-- script.html -->
...
<body>
<input type="text" maxlength="9" pattern=".{9}" onkeyup="checknric(this)" required />
</body>
...
<script src="https://unpkg.com/sgidvalidator@1.0.7/dist/js/nricvalidator.js"></script>
<script>
function checknric(element) {
var valid = nricvalidator.validate(element.value);
if (!valid) alert("invalid!");
}
</script>
npm i nricvalidator
import { validate } from "sgidvalidator";
const isValid = validate("S1234567H");