views:

165

answers:

2

dear friends

I am looking for numeric textbox control based on mootools framework.

i'd be grateful if someone help me to find or implement this control.

thank you . Alimz

A: 

not sure if this is what you mean but:

mootools formcheck is a class-based semantic solution which relies on css classes to define a ruleset for each input field. For example:

<input class="validate['required','number']" />

Pretty flexible and pretty cool, thumbs up from me and the idea of a hash based ruleset within the element’s class is just great.

mootools iMask by Fabio Nagao is something similar to formcheck, but it takes matters further. iMask actually attaches itself to the input element and helps the user populate their data as per a pre-set ‘mask’. The mask is just a patterned format that cannot be broken. In reality, it allows you to ask your user to enter really complex data blocks, for example, you can have a field that contains (+NN)-NNN-AZ, hyphens, brackets and plus sign included. The end-user can only enter numerics or alpha characters in their designated places. Check it out, it’s really impressive

Dimitar Christoff
+1  A: 

You can also easily write this yourself.

var isNumberKey = function(e){
    if (e.code > 31 && (e.code < 48 || e.code > 57)) 
        return false;   
    return true;
}

var isBackSpaceKey: function(e){
    return e.code == 8;
}

var isArrowKey: function(e) {
    return e.code >= 37 && e.code <= 40;
}

var inputs = $$('.width-input', '.height-input');
inputs.addEvent('keyup', function(e){
  if (!isNumberKey(e) && !isBackSpaceKey(e) && !isArrowKey(e)) 
            e.stop();
});
Randy Simon