0

I'm using JSF 2.0, jquery 1.9 and javascript. I also have RichFaces (no PrimeFaces). I have a serial number input field. The serial number has this format

ABCD-1234-EFGH-5678

It can have any combination of numbers and digits. The only restrictions are: 1) Alphanumeric 2) 16 characters exactly

Now, for user's comfort, I need to dyamically add the '-' every 4 characters (except, of course, at the very end). I have no idea if this is possible with what I have. Any ideas?

Thanks!

-EDIT-

So, I'm using the jQuery.MaskedInput.js option. Here's my code

<script type="text/javascript">
    // <![CDATA[
    jQuery(function($){
        $("#managerForm\\:computername1").mask("****-****-****-****",{placeholder:"Add Computer ID"});
        $("#managerForm\\:computername2").mask("****-****-****-****",{placeholder:"Add Computer ID"});
        $("#managerForm\\:computername3").mask("****-****-****-****",{placeholder:"Add Computer ID"});
    });
    // ]]>
</script>

But it's not working. The console says there's an uncaught error.

Object [object Object] has no method 'mask'

I'm importing this

<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.maskedinput.js" type="text/javascript"></script>

Any ideas?

Nacho321
  • 1,911
  • 7
  • 33
  • 55
  • 1
    See if this Q&A helps http://stackoverflow.com/questions/11632525/insert-dash-after-every-4th-character-in-input – Vlad Sep 24 '13 at 20:08
  • possible duplicate of [How use mask in input field in JSF 2 + RichFaces 4?](http://stackoverflow.com/questions/7883262/how-use-mask-in-input-field-in-jsf-2-richfaces-4) – BalusC Sep 24 '13 at 20:16
  • By the way, FYI, PrimeFaces supports it out the box with ``: http://www.primefaces.org/showcase/ui/inputMask.jsf – BalusC Sep 24 '13 at 20:17

0 Answers0