Demo entry 6716203

js + jsx

   

Submitted by tiffon on Feb 16, 2018 at 16:51
Language: JavaScript. Code size: 660 Bytes.

<TxRegionsInput
    validators={(text, markRange) => {
        const letters = 'abcdefghijklmnopqrstuvwxyz';
        const lower = text.toLowerCase();
        let invalid = false;
        let i = 0;
        for (; i < letters.length; i++) {
            if (lower.length < i) {
                return `incomplete-alphabet ${invalid ? 'invalid-letters' : ''}`;
            }
            if (lower[i] !== letters[i]) {
                invalid = true;
                if (markRange) {
                    markRange(i, i+1, 'invalid-letter');
                }
            }
        }
        return invalid ? 'invalid-letters' : false;
    }}
/>

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).