developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.
Opened 13 years ago
Closed 12 years ago
#636 closed bug (fixed)
Javascript error handling does not work for element <checkboxes>
Reported by: | bballizlife | Owned by: | Julien |
---|---|---|---|
Priority: | normal | Milestone: | Jelix 1.1 beta 1 |
Component: | jelix:forms | Version: | trunk |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | #635 | Documentation needed: | no |
Hosting Provider: | Php version: |
Description
Situation:
- Using a <checkboxes> element with the required attribute
- Submitting the form without ticking any item of the <checkboxes>
Error:
- No javascript error telling that the element is required
Working:
- server-side check is working and we have the error message telling that we must tick and item
Attachments (2)
Change History (18)
comment:1 follow-up: ↓ 4 Changed 13 years ago by bballizlife
comment:2 Changed 13 years ago by laurentj
- Milestone set to Jelix 1.1 beta 1
comment:3 Changed 13 years ago by bastnic
- Owner set to bastnic
- Status changed from new to assigned
comment:4 in reply to: ↑ 1 Changed 12 years ago by Julien
Replying to bballizlife:
Addon:
- after further tests, this only appears if there is only 1 item in the <checkboxes> element.
So if ticket #635 is accepted, we may close this one in won't fix as <checkboxes> could implies the use of 2 items at least. (for 1 item developer must use <checkbox>).
Hi,
I must add the following : checkboxes element can be filled with items from a dao, for example to set categories for a product. Then categories are mandatory, but we can never be sure that there will ever be at least 2 categories. As we can't know the number of items in the checkboxes element, required attribute must also work if there is only one.
So the javascript check has to be improved. I can do it if you want, as I'm working on a lot of little things in jForms these days. Let me know.
comment:5 Changed 12 years ago by bballizlife
I won't have time these days to improve it. So if you can work on it it would be great. Thanks !
Changed 12 years ago by Julien
comment:6 Changed 12 years ago by Julien
- Owner changed from bastnic to Julien
- review set to review?
- Status changed from assigned to new
Here's the patch.
I also simplified the code
comment:7 Changed 12 years ago by Julien
- Status changed from new to assigned
comment:8 Changed 12 years ago by Julien
- Blocking 635 added
comment:9 Changed 12 years ago by laurentj
The patch is ok, but I really would like to have unit test !
comment:10 Changed 12 years ago by laurentj
oups, sorry, wrong ticket
comment:11 Changed 12 years ago by laurentj
It seems ok for me, except this :
+ for (var i = 0; i < elt.options.length; i++) { + if (elt.options[i].selected) + values.push(elt.options[i].value); }
Are your sure that a select element have an options property on all browser ?
comment:12 Changed 12 years ago by laurentj
Ok, this in the DOM HTML spec : http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-30606413
But we should verify that it is really implemented (IE for example)...
comment:13 Changed 12 years ago by Julien
I'll try on every browser I have installed and confirm if it works. I've used this property for a long time now, didn't have any problems.
comment:14 Changed 12 years ago by Julien
Hello,
checked that "options" property for select element works on following browsers :
- Firefox 3 on linux / windows
- Opera 9 on linux / windows
- Google Chrome on windows
- IE 5.1 to 7 on windows
- Safari 3 on windows
don't have a Mac anymore here, but I'm sure it works for Firefox/Opera/Safari? as these are standard compliant browsers for a long time now.
So I think this patch can be committed without any problem
comment:16 Changed 12 years ago by Julien
- Resolution set to fixed
- Status changed from assigned to closed
committed in the trunk
Addon:
So if ticket #635 is accepted, we may close this one in won't fix as <checkboxes> could implies the use of 2 items at least. (for 1 item developer must use <checkbox>).