Chrome caches select menu - html

I have a select menu.
Example:
<select autocomplete="off"> <option value="" selected="selected">Select Quantity</option>
<option value="6" autocomplete="off">6</option>
<option value="12" autocomplete="off">12</option>
<option value="18" autocomplete="off">18</option>
<option value="24" autocomplete="off">24</option>
</select>
If the user selects a value and then navigates to a different page and back...the browser caches the selected value (even though I have switched off caching in the cache related headers).
How can I prevent Chrome from caching these select values?

Add autocomplete="off" to the form (not the select element):
<form autocomplete="off">
<select> <option value="" selected="selected">Select Quantity</option>
<option value="6" autocomplete="off">6</option>
<option value="12" autocomplete="off">12</option>
<option value="18" autocomplete="off">18</option>
<option value="24" autocomplete="off">24</option>
</select>
</form>

Related

How to require a selection in my select element on my signup form [duplicate]

This question already has answers here:
How do I make a field required in HTML?
(16 answers)
Closed 2 months ago.
<label for="select-choice">Birthday:</label>
<select name="select-choice" id="select-choice">
<option value="0" selected disabled>Month</option>
<option value="january">Jan</option>
<option value="february">Feb</option>
<option value="march">Mar</option>
<select name="birthday-day" id="day">
<option value="0" selected disabled>Day</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<select name="birthday-year" id="year">
<option value="0" selected disabled>Year</option>
<option value="2015">2015</option>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
The Sign Up or Register page is okay but I could not validate the birthday, When I try filling it on a browser I expect it to demand or require birthday option, every other input option was demanding or requiring me to input an information but if I purposely did not fill the birthday and hit the submit button it will go through just like that, please how do I validate the birthday using HTML?
You just need to add "required" to each of your selects and then just add an empty value instead of a "0" value. When you press a button, it will detect it has no value and will automatically make the select required.
<form>
<label for="select-choice">Birthday:</label>
<select name="select-choice" id="select-choice" required>
<option value="">Month</option>
<option value="january">Jan</option>
<option value="february">Feb</option>
<option value="march">Mar</option>
</select>
<select name="birthday-day" required>
<option value="">Day</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<select name="birthday-year" id="year" required>
<option value="">Year</option>
<option value="2015">2015</option>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
</select>
<button>submit</button>
</form>

Chrome Credit Card Autofill Field Name Bug/Conflict

Does anyone know why a form field name would cause Chrome's autofill to stop working correctly? If you open the fiddle I've created in Chrome, you'll notice the Card Number field populates correctly, but not the expiry month and year. If you change the name of the BirthDate.MM select list to BirthDate.Foo and BirthDate.YYYY to BirthDate.Bar; and then and re-run, the credit card autofill works as expected. Now, an obvious suggestion would be to simply disable the bday- autofill and change the those values to "off" or completely remove the autocomplete attribute. Astoundingly, removing the autocomplete attribute or changing the bday- values to "off" on those fields then breaks the address autofill!!!
The solution to the autofill problem itself is simply change the field names. What I want to know is why? Can anyone clarify how I unwittingly poked Chrome's field name sniffing feature?
<fieldset>
<legend>Payment Information</legend>
<div><input autocomplete="cc-number" id="CreditCard_CardNumber" maxlength="16" name="CreditCard.CardNumber" pattern="\d*" required="" type="text" placeholder="Card Number" value="" /></div>
<div>
<label for="CreditCard_ExpirationMonth">Expires:</label>
<select autocomplete="cc-exp-month" id="cardExpirationMonth" name="CreditCard.ExpirationMonth" required="">
<option value="">Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select autocomplete="cc-exp-year" id="cardExpirationYear" name="CreditCard.ExpirationYear" required="">
<option value="">Year</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
<option value="2025">2025</option>
<option value="2026">2026</option>
<option value="2027">2027</option>
<option value="2028">2028</option>
<option value="2029">2029</option>
<option value="2030">2030</option>
<option value="2031">2031</option>
<option value="2032">2032</option>
<option value="2033">2033</option>
<option value="2034">2034</option>
<option value="2035">2035</option>
<option value="2036">2036</option>
<option value="2037">2037</option>
</select>
</div>
</fieldset>
Use the lower-case version of your names.
For me , using Name as name attribute is not working, autofill recognizes the field as CC !!
If I change it to name , works like a charm.
Hope this helps!

iPad Chrome HTML click select option, but display another option

In PC Chrome & IE, it works. But in iPAD Chrome, when I select month or year, it display the option of day. And the code related as below.
<td class="label" nowrap="nowrap"><label for="InputLabel2">Fax Received Date To</label></td>
<td><label>
<INPUT TYPE="HIDDEN" NAME="InputLabel2" VALUE="D/2014/10/22:17:19:28">
<INPUT TYPE="HIDDEN" NAME="InputLabel2_dirtyFlag" VALUE="0">
<LABEL FOR="InputLabel2_day"></LABEL>
<SELECT ID="InputLabel2_day" TITLE="Day" NAME="InputLabel2_day" onChange="InputLabel2_update(this, this.form, null)">
<OPTION VALUE="-1" >
<OPTION VALUE="1" >1
<OPTION VALUE="22" SELECTED>22
<OPTION VALUE="31" >31
</SELECT>
---
<LABEL FOR="InputLabel2_month"></LABEL>
<SELECT ID="InputLabel2_month" TITLE="Month" NAME="InputLabel2_month" onChange="InputLabel2_update(this, this.form, null)">
<OPTION VALUE="-1" >
<OPTION VALUE="1" >January
<OPTION VALUE="10" SELECTED>October
<OPTION VALUE="12" >December
</SELECT>
---
<LABEL FOR="InputLabel2_year"></LABEL>
<SELECT ID="InputLabel2_year" TITLE="Year" NAME="InputLabel2_year" onChange="InputLabel2_update(this, this.form, null)">
<OPTION VALUE="-1" >
<OPTION VALUE="2013" >2013
<OPTION VALUE="2014" SELECTED>2014
<OPTION VALUE="2015" >2015
</SELECT>
find the issue, it is due to , it should not have the additional after , and once remove it, it works in iPad Chrome now. Thx all

For following drop down list , 'required' attribute is not working

If user selects " - - select - -" from options , it should be treated as blank field. It should trigger 'required' attribute so that the browser would show alert message while submitting the form as: "Please fill out this field" .
I tried hard but no solution found.
HTML:
<form>
<select id="post" name="post" required="required" title="post you are applying for" class="formfield3" />
<option value="0"> - - select - -</option>
<option value="1">Mobile App Developer</option>
<option value="2">DataBase Administrator</option>
<option value="3">Search Engine Optimizer</option>
<option value="4">Product Manager</option>
<option value="5">HR Manager</option>
</select>
<input type=submit>
</form>
I am using newest version chrome and 'required' is working for other tags such as textfields etc.
To make browser treat it as a blank field, make it blank - change 0 to an empty string:
<select id="post" name="post" required="required" title="post you are applying for" class="formfield3" />
<option value=""> - - select - -</option>
<option value="1">Mobile App Developer</option>
<option value="2">DataBase Administrator</option>
<option value="3">Search Engine Optimizer</option>
<option value="4">Product Manager</option>
<option value="5">HR Manager</option>
</select>
Following code did not work for me:
<select id="example1" name="example1" required="required" />
<option value="0"> - - select - -</option>
<option value="1">A</option>
<option value="2">B</option>
</select>
Following code worked for me:
<select id="example1" name="example1" required="required" />
<option value=""> - - select - -</option>
<option value="1">A</option>
<option value="2">B</option>
</select>
The difference being value="" vs value="0"

Include hidden input with optgroup

Is it possible to to include multiple (or a single) <input type = hidden> nested within an <optgroup>'s <option>?
For example, I might have
<select>
<optgroup label="North America">
<option value="Canada">Canada</option>
<input type="hidden" name="capital" value="Ottawa">
<option value="United States">United States</option>
<input type="hidden" name="capital" value="Washington D.C.">
<option value="Mexico">Mexico</option>
<input type="hidden" name="capital" value="Mexico City">
</optgroup>
...
</select>
If I choose "Canada" could I get "Ottawa" and only "Ottawa" submitted also?
What you are asking for is not exactly possible, but it sounds like the result you want is...
<select name="capital">
<optgroup label="North America">
<option value="Ottawa">Canada</option>
<option value="Washington D.C.">United States</option>
<option value="Mexico City">Mexico</option>
</optgroup>
...
</select>
When the user selects "Canada" from the drop-down, the value "Ottawa" will be submitted to the server.