views:

815

answers:

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?

A: 

Looks like that's possible... Did you try? Can you explain the trouble you had?

thenduks
+1  A: 

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);
  }
});
Matt
+3  A: 

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

Aaron Smith
+1  A: 

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).

Chad