tags:

views:

254

answers:

1

I have the following code:

<input type="text" dojoType="dijit.form.NumberTextBox" size=8 constraints="{min:0,max:100000,places:0}" id="orgNumberOfStudents" name="orgNumberOfStudents" required="true" invalidMessage="Integer between 0 and 100,000" value="">

Questions:

1) How do I set the width of the box? Do I have to do it in a style tag or a CSS? Is the traditional "input size" tag ignored?

2) The above sample shows the error when I type in a non-numeric value. But if I tab over the field and don't fill in anything, it's still blank. Is there a quick way to enforce the validation when I click the submit button? Do I need a Dijit submitt button? Do I need to write more JavaScript to make this happen? How does the required="true" actually occur?

(One get-around is to set the value to 0, but I'd rather force the user enter a value rather than just defaulting it).

Thanks, Neal Walters

+1  A: 

You should be able to use both CSS and traditional INPUT attributes like "maxLength" on your NumberTextBox by passing them in to the Widget's constructor. maxLength is available on all dijit.form.TextBox subclasses, but is probably less useful here since you have control over things like min/max and the actual number format.

Yes, you can always write your own JS to test "isValid()" on your widget instance before submission, e.g. in an HTML FORM onSubmit handler, or you could use dijit.form.Form which will check validity for you. The widget itself is only responsible for visual representation of its own validity, according to the options chosen.

HTH

peller
Thanks. size=5 doesn't seem to be setting the size of the box. It's not maxlength I'm interested in, but it's how wide the box is on the screen. So can I do it without using a style="" parm?
NealWalters
AFAIK, you have to use style
peller