auto_numeric_js icon indicating copy to clipboard operation
auto_numeric_js copied to clipboard

Min/Max values Not Working

Open toddca opened this issue 11 years ago • 3 comments

Setting a min value of 1900 and max value of 2013 I cannot type into the input element. Even if I set the default value of the element to 1900 I still cannot change the value. This works with min=0 and max=2013 but not when min>9. Tested on FireFox V15.

input type="text" value="" name="PlainNumberMaxMin" id="PlainNumberMaxMin" data-val-number="The field Plain Number Max Min must be a number." data-val-min-numeric="1900" data-val-max-numeric="2011" data-val="true" class="t-format-plainnumber input-medium valid" autocomplete="off"

$('#t-main-form').find("input.t-format-plainnumber").each(function () {

    var maxValue = $(this).attr("data-val-max-numeric");
    var minValue = $(this).attr("data-val-min-numeric");

    if (maxValue == null) maxValue = 999999999;
    if (minValue == null) minValue = 0;

    var options = { mDec: 0, vMin: minValue, vMax: maxValue, aSep:'' };

    if (minValue > 0) {
        $(this).val(minValue);
    }

    $(this).autoNumeric(options);
    if ($(this).val() != '') {
        $(this).autoNumericSet($(this).val());
    }

});

toddca avatar Sep 27 '12 14:09 toddca

Todd,This behavior is an issue when the min max values are relatively close because changing the values violates the min\max rules. I suggest that you set the min value to zero and validate the value on focusout.Version 1.8.0 (http://www.decorplanit.com/plugin/autoNumeric-1.8.0-beta.htm) will be released soon. Just need to update the documentation. It is a nice improvement.Best regards,Bob 

-------- Original Message -------- Subject: [auto_numeric_js] Min/Max values (#6) From: Todd Carter [email protected] Date: Thu, September 27, 2012 7:53 am To: funny-falcon/auto_numeric_js [email protected] a min value of 1900 and max value of 2013 I cannot type into the input element. Even if I set the default value of the element to 1900 I still cannot change the value. This works with min=0 and max=2013 but not when min>9. Tested on FireFox V15. $('#t-main-form').find("input.t-format-plainnumber").each(function () { var maxValue = $(this).attr("data-val-max-numeric"); var minValue = $(this).attr("data-val-min-numeric");

if (maxValue == null) maxValue = 999999999;
if (minValue == null) minValue = 0;

var options = { mDec: 0, vMin: minValue, vMax: maxValue, aSep:'' };

if (minValue > 0) {
    $(this).val(minValue);
}

$(this).autoNumeric(options);
if ($(this).val() != '') {
    $(this).autoNumericSet($(this).val());
}

}); — Reply to this email directly or view it on GitHub.

BobKnothe avatar Sep 27 '12 17:09 BobKnothe

Thanks Bob - so are you saying 1.8 addresses this issue?

What I am trying to do is have an input element where someone was enter in a year. The year represents the year model of your car, truck or van so a drop down list is not something we want based on the large number of possible values. The idea is to have someone type in a number only, no comma, and have the value validate good when the number is between 1900 and current year + 1 (2013).

I believe the core issue is that to type a number 1999 you must first type 1 then 19, then 199 and each of these values is less than the min value therefore not accepted by the autoNumeric plugin.

Thanks again for your help and great plugin.

toddca avatar Sep 27 '12 17:09 toddca

Todd,

No it does not address this behavior.

It just has some cool new features.

Bob

Robert (Bob) Knothe

On Sep 27, 2012, at 10:47 AM, Todd Carter [email protected] wrote:

Thanks Bob - so are you saying 1.8 addresses this issue?

What I am trying to do is have an input element where someone was enter in a year. The year represents the year model of your car, truck or van so a drop down list is not something we want based on the large number of possible values. The idea is to have someone type in a number only, no comma, and have the value validate good when the number is between 1900 and current year + 1 (2013).

I believe the core issue is that to type a number 1999 you must first type 1 then 19, then 199 and each of these values is less than the min value therefore not accepted by the autoNumeric plugin.

Thanks again for your help and great plugin.

— Reply to this email directly or view it on GitHub.

BobKnothe avatar Sep 27 '12 18:09 BobKnothe