1

I found this definition as an answer by "popo" to another question:

$.mask.definitions['h'] = "^[\\\\/:*?\"<|]?[\\\\/:*?\"<|]*";
           //period was here ^

but for some reason this allows periods, even though I removed the period from the definition (it was inside the first opening bracket).

I just want a definition that allows the generic alphanumeric, and some special characters like slashes, dashes, and underscores. How can I change the definition above to do that?

5
  • it should catch periods. did you try doing a hard refresh in your browser? your browser might be caching the previous js. Commented Jan 21, 2015 at 17:26
  • hm.. I thought I did. I'll try again Commented Jan 21, 2015 at 21:16
  • @mikelt21 nope.. just tried it, restarted the server and browser, still not catching the periods Commented Jan 21, 2015 at 21:18
  • okay could you link me to the other question you referenced that regex from? Commented Jan 21, 2015 at 21:54
  • @mikelt21 hey sorry for the late response, I was busy yesterday, here's the link stackoverflow.com/questions/22731654/… Commented Jan 22, 2015 at 13:05

1 Answer 1

1

If you just need alphanumeric, slash, dash and underscore, then you can use the following:

$.mask.definitions['h'] = "[A-Za-z0-9\/\-_]";
Sign up to request clarification or add additional context in comments.

13 Comments

why's this adding a big line to the input field? the line disappears where I type text, but the rest of the line stays to the right. The line is showing up when I click on the input field
is it underscores? like _____? does it disappear character by character as your type into the field? if so that's just the placeholder. by default maskedinput uses "_" as the placeholder per character. you can change it when you call the mask function by doing something like $('input').mask({ placeholder: '' }). that will set the placeholder to be nothing.
if it's not then could you provide a screen shot of what's going on?
yea that's what it was, and I'm using the input as a file name, so the file name is coming up as "myFileName________", I'll try the fix you suggested
oops sorry it should be $('input').mask('hhh?hhhhhh', {placeholder: ''});
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.