2

How to forbid user to type not valid roman numerals on input stage in textbox. For example: VV or IXI are not valid roman numerals, so I want to develop functional that would not allow user to type V after V or I after IX. I have tried this (meioMask plugin):

  function addMasks() {
      jQuery.mask.rules = {
                  'A': /^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,  
                  $('#<%=tbSeries.ClientID%>').setMask('AAAAAAA');       
      };

but this mask working only for each symbol, but not for whole number.

Andrei Karcheuski
  • 3,116
  • 3
  • 38
  • 39

1 Answers1

0

The regex is correct, but it looks like the meioMask code is not right.

Try this:

$.mask.masks.roman = {mask: 'M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})'};
$('#<%=tbSeries.ClientID%>').setMask('roman');

The regex covers the entire numeral, not each digit. So use the regex as the complete mask (not repeated like AAAAAAA).

Brian Stephens
  • 5,161
  • 19
  • 25