I'm using a NumberTextBox and want to control the input in a way that the following requirements are met:
a) no + or - should be allowed b) values must be between e.g. 4.5 and 19.8 c) the allowed format should be at most two digit开发者_高级运维s before the '.' and not more than 4 after it. d) thus the control should hold at most 7 characters and must not allow to enter moreAside from the error message for violating b) I don't want to see any messages. I want it to be impossible to enter a third digit before or a 5 fifth digit after the '.'
The best approach I manages to get was using - maxLength="7" - constraints={min="4.5",max="19.8",pattern="#0.####"} but that fails to do the task. I also tried with different patterns and making use of 'precision' but still was not able to get what I want.Is it possible at all? Or do I need to write extra code for this?
Thanks for your time!
I seem to recall someone asking this in the IRC channel once, and the answer was that pre-emptively blocking invalid input altogether was attempted at one point but ended up being too troublesome to go through with. So the OOTB validation in these widgets is purely reactive, not preventative.
This test page gives some idea of the kinds of things you can do with validation OOTB:
http://download.dojotoolkit.org/release-1.5.0/dojo-release-1.5.0/dijit/tests/form/test_validate.html
精彩评论