#8977 closed defect (fixed)
dijit.form.Form.isValid return Numer 0 instead true and 1 instead false
Reported by: | niquola | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.3 |
Component: | Dijit - Form | Version: | 1.3.0b3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
here form example
<form dojoType="dijit.form.Form" dojoAttachPoint="form"> <p dojoAttachPoint="splashNode" class="${baseClass}Splash"></p> <p> <label class="${baseClass}Label" for='summary'>Summary:</label> <input class='' dojotype='dijit.form.ValidationTextBox' name='summary' style='width:100%;' title='summary' type='text' required='true' invalidMessage="Summary is required."/> </p> <p> <button class="${baseClass}Button" dojoAttachPoint="submitButton" dojotype='dijit.form.Button' >Submit</button> </p> </form>
and handling
dojo.connect(this.submitButton, 'onClick', function() { console.log(form.isValid()); // log 0 if field is not empty and 1 if empty } });
Change History (9)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Well, we could make it a boolean with just 2 additional chars (!!) and then add jsdoc to indicate that this function has a Boolean return value. Right now, I guess that's just supposed to be understood, and the user should be using truthy/falsey expressions to deal with the result. If we don't define isValid's return type, could that lead to trouble?
comment:3 Changed 12 years ago by
the problem is not the type of returned value, but that the logic is wrong - 0 returned when form is valid is falsy!
comment:4 Changed 12 years ago by
Owner: | set to Douglas Hays |
---|
yikes. How could we fix that without breaking compatibility? We might have to leave it as is and document it clearly.
comment:5 Changed 12 years ago by
so should we treat this correct: if(form.isValid()==0){
submit form
}else{
warn user that form is not valid
} ???
comment:6 Changed 12 years ago by
ups :( so should we treat this correct:
if(form.isValid()==0){ //submit form }else{ //warn user that form is not valid }
???
comment:7 Changed 12 years ago by
Milestone: | tbd → 1.3 |
---|---|
Owner: | changed from Douglas Hays to bill |
Status: | new → assigned |
Oh sorry, I broke this recently in [17106], will fix.
comment:8 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
OK, fixed in [17120], thanks for catching that. Will add a test for this to the unit test later.
comment:9 Changed 10 years ago by
Component: | Dijit → Dijit - Form |
---|
That's true, is that a problem (and if so, why)?