Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML form with prefill doesn't get submitted in Chrome
    primarykey
    data
    text
    <p>My code works in all major browsers, except for Google Chrome, where it's acting weird. I'm using Google Chrome 11.0.696.68. These facts apply for Chrome:</p> <ul> <li>If I give values to all input fields, I can submit the form without any trouble.</li> <li>If I leave the field 'day' blank and press the submit button, the form is not submitted, but the focus goes to the day field, for some reason.</li> <li>If I give the focus to any field other than 'day', e.g. 'other', and press enter, the form is not submitted and the focus goes to the day field again.</li> <li>If I give the focus to the empty day field and press enter, the form IS submitted.</li> <li>If I comment out the line <code>prefillTextfield( 'candidate_dateOfBirth_day', 'Day' );</code>, everything work fine. The weird thing is that there still is a similar field which doesn't cause any problems: year.</li> </ul> <p>Is this a bug in Google Chrome or is it in my code?</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;title&gt;Submit fails in Google Chrome&lt;/title&gt; &lt;script type="text/javascript" src="hidden/js/jquery-1.4.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; /** * Prefill a textfield */ function prefillTextfield( id, defaultText ) { var element = $( '#' + id ); var color = 'rgb(153, 153, 153)'; // Define focus event element.focus( function() { if( element.css( 'color' ) == color ) { element.val( '' ); element.css( { 'color': '#000' } ); } } ); // Define blur event element.blur( function() { if( element.val().length == 0 ) { element.val( defaultText ); element.css( { 'color': color } ); } } ); // Simulate onblur event. element.trigger( 'blur' ); } $( document ).ready( function() { prefillTextfield( 'candidate_dateOfBirth_day', 'Day' ); prefillTextfield( 'candidate_dateOfBirth_year', 'Year' ); } ); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form onsubmit="javascript: alert( 'Submitted!' ); return false;"&gt; &lt;div class="formField"&gt; &lt;label name="dateOfBirth-label"&gt;Date of birth&lt;/label&gt; &lt;input type="text" class="textField" id="candidate_dateOfBirth_day" name="candidate_dateOfBirth_day" maxlength="2" style="width: 60px;" /&gt; &lt;select id="candidate_dateOfBirth_month" name="candidate_dateOfBirth_month" style="width: 90px; color: #999;"&gt; &lt;option value="" style="color: #999;"&gt;Month&lt;/option&gt; &lt;option value="01" style="color: #000;"&gt;January&lt;/option&gt; &lt;option value="02" style="color: #000;"&gt;February&lt;/option&gt; &lt;option value="03" style="color: #000;"&gt;March&lt;/option&gt; &lt;option value="04" style="color: #000;"&gt;April&lt;/option&gt; &lt;option value="05" style="color: #000;"&gt;May&lt;/option&gt; &lt;option value="06" style="color: #000;"&gt;June&lt;/option&gt; &lt;option value="07" style="color: #000;"&gt;July&lt;/option&gt; &lt;option value="08" style="color: #000;"&gt;August&lt;/option&gt; &lt;option value="09" style="color: #000;"&gt;September&lt;/option&gt; &lt;option value="10" style="color: #000;"&gt;October&lt;/option&gt; &lt;option value="11" style="color: #000;"&gt;November&lt;/option&gt; &lt;option value="12" style="color: #000;"&gt;December&lt;/option&gt; &lt;/select&gt; &lt;input type="text" class="textField" id="candidate_dateOfBirth_year" name="candidate_dateOfBirth_year" maxlength="4" style="width: 60px;" /&gt; &lt;/div&gt; &lt;div class="formField"&gt; &lt;label name="dateOfBirth-label"&gt;Other input field&lt;/label&gt; &lt;input type="text" class="textField" id="other" name="other" style="width: 60px;" /&gt; &lt;/div&gt; &lt;div class="formField"&gt; &lt;label name="dateOfBirth-label"&gt;&amp;nbsp;&lt;/label&gt; &lt;input type="submit" class="textField" value="Submit" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Thanks in advance!</p> <p>JSFiddle - <a href="http://jsfiddle.net/chin/MyewW/1/" rel="nofollow">here</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload