Take the 2-minute tour ×

Help me with masked input mask for roman numeral. I need to create a mask with which I can input only roman number from I to X

share|improve this question
Do you have a plugin for validation? –  Nirazul Nov 26 '12 at 19:58
In this case, it's probably easiest to test against all ten valid values. –  Blazemonger Nov 26 '12 at 20:01
Use a dropdown? –  valentinas Nov 26 '12 at 20:04
thanks, dropdown is the best way! –  Александр Брус Nov 27 '12 at 6:45

1 Answer 1

If you don't use a plugin, the easiest way is to write a regex and match an input value against it. If found a really really nice one here

    var strInput = $('input#myRomanInputField').val();
    var matchArr = strInput.match(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/g);
    if(matchArr) {
        // test successful
    } else {
        // failure

For numbers 1-10, just use this regex:

share|improve this answer

Your Answer


