nanopython  /  validation

Form validation, Python on both sides

The Python rules in validators.py are lifted verbatim from Prescrypt's validation-library demo. Clicking Validate hands control to main.py, which reads each field, runs the validators, and writes errors straight back into the DOM via the ADR-006 js bridge — no stdout protocol. The same module would run on the server.

Loading…

Notes

Each click spins up a fresh wasm instance: main.py reads document.getElementById(id).value, calls the validator, then writes err/ok classes and the error message back via js.document. JS supplies only the wasm loader and bridge wiring; Python owns the DOM. Try 4111 1111 1111 1111 (a known-good Luhn test number) versus a random digit string for the card field.