[MAGNOLIA-242] Problem with mandatory check of sample form template Created: 11/Dec/04  Updated: 16/May/06  Resolved: 16/May/06

Status: Closed
Project: Magnolia
Component/s: samples
Affects Version/s: 2.0 Final
Fix Version/s: 3.0 RC1

Type: Bug Priority: Major
Reporter: sala Assignee: Boris Kraft
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OS X, safari


Attachments: File form.js.diff    
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Mandatory form check does not work on safari. The problem is the naming of the form elements (as "0", "00", "01", "02" and so on - see files /templates/jsp/samples/templateForm/paragraphs/edit.jsp and /templates/jsp/samples/templateForm/paragraphs/selection.jsp).

reason:
------

if there is an html code like this:

<form name="someform" onsubmit="return (checkMandatories(this.name,'whatever'));">
text: <textarea name="01"></textarea><br />
<input name="02" type="checkbox" value="1">1<br />
<input type="submit" />

then, in javascript of safari,

document.forms["someform"].elements["01"].type

will return "checkbox" in safari, although the element is in fact a textarea - this will mess up the whole mandatory procedure.

Fix:

Safari obviously treats the string "01" as a number and returns the type of elements[1] - which is indeed the checkbox. Whether this is a bug in safari or not is beyond my knowlegde of the ECMAScript specs. Simple change the namings of the form elements to e.g. "element_01" and "element_02" in the above mentioned files, and also in the file /templates/jsp/samples/templateForm/main.jsp (lines 126 and 127).

Sala



 Comments   
Comment by Jon Gibbens [ 02/Sep/05 ]

This bug also affects Internet Explorer 6.

Comment by Ed Chang [ 01/Oct/05 ]

Diff of form.js with trivial fix for incorrect form-field validation when using Internet Explorer 4.x or higher for PC. A more robust solution is to output HTML with better name/value pairs.

The problem: Internet Explorer's implementation of JScript interprets "0377" as an octal integer and converts it to a decimal equivalent of "255". Additionally, IE will convert "0378" to a decimal equivalent of "378". In the case of parsing mandatory form fields, IE will begin searching for form.elements[0] rather than form.elements["00"].

A solution: This fix simply tests for IE's proprietary DOM model with "document.all" and assigns a node-parsing method to a variable, that IE and DOM Level 1 browsers can understand.

  • form() for IE
  • form[] for DOM 1+ browsers
Comment by Fabrizio Giustina [ 09/Oct/05 ]

patch committed to svn. Should be fixed in IE, but still broken on Safari.

Comment by Philipp Bracher [ 16/May/06 ]

01 is not a valid field name!

alert(document.samplesForm.01) will even not compile!

looks like the code was even not working properly on firefox.

Only valid way to fix this is to use a prefix field_01.

Comment by Philipp Bracher [ 16/May/06 ]

fixed through adding field_ prefix

Generated at Mon Feb 12 03:15:29 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.