4

I was trying to mask a text field and took a look at http://digitalbush.com/projects/masked-input-plugin/

Has anyone used this plugin before?

I am trying to mask a text field so that users are only able to enter some dollar amount to it. dollar amount can be between 0 - 500000

Is that feasible through this plugin?

4 Answers 4

4

Masked input plugin can only do fixed length fields. It can also do partial inputs, but only on the end of the field.

Sign up to request clarification or add additional context in comments.

Comments

2

Trying to make a mask for a range will just annoy users. Instead, use the blur event to check the range when the focus leaves the text field.

$('#yourinput').blur(function() {
  val dollarAmount = parseInt($(this).val());
  if (dollarAmount < 0) {
    $(this).val(0);
  } elseif (dollarAmount > 500000) {
    $(this).val(500000);
  }
});

Comments

1

I've liked working with the masked input plugin as well, and was looking to create the same thing. I agree with Aaron above that I don't believe the jBush Masked Input plugin currently supports it that I can find. Although I think jBush has been looking at making this: http://forum.jquery.com/topic/jquery-masked-input-plugin-direction

I've been looking around for the same thing. So far the closest thing I found, which I'm settling for at the moment, is this alphanumeric plugin: http://itgroup.com.ph/alphanumeric/

To address your question you can set it to allow numeric only, plus a few extrax (comma, decimal).

Comments

1

All of the plugins I found have some annoyances or strange behavior (cursor jumps to end, text can't be selected using shift+arrow keys, etc), but this one has the least of these problems I could find:

https://github.com/plentz/jquery-maskmoney

Sorry to dig up this old thread, but I ended up using this plugin, might be useful for someone stumbling on this thread (like me)

Comments

Your Answer

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