HTML5 datalist autocomplete dropdown not working on iOS - ios

I see this question, which is similar, but looks like no one was able to answer it.
I decided to implement an autocomplete dropdown with the HTML5 datalist, because I have about 1,000 items I'd like mobile users to be able to start typing and narrow the list down. Seems to work great on my Android, but on iOS no options come up at all.
Is this a known issue? I can't seem to find much info on it. I am thinking I will be looking hard for a screen position error (e.g., maybe the options are coming up off to the side of the screen area for some reason), but I'm baffled what else would cause this.
Here's the HTML:
<p>School 1</p>
<input type="text" id="input1" name="school" list="dlSchool1" class="collegeListInput" placeholder="Type a school's name..." />
<datalist id="dlSchool1">
<asp:Repeater ID="rpMobile" runat="server">
<ItemTemplate>
<option value="<%# Eval("SchoolName")%>"><%# Eval("SchoolName")%></option>
</ItemTemplate>
</asp:Repeater>
</datalist>
And some CSS:
.collegeListInput {
width: 225px;
margin-top: 20px;
}
In JQuery I do some stuff on the focusout event.
That's about it. Thanks in advance for any advice / resources. I'm on hour 14 of the workday, so be gentle if this is a really dumb question.

The datalist is not supported on iOS yet (note to visitors from the future, as of Oct 6, 2014 the current version of iOS is 8.0.2).
Can I Use - Datalist

Related

Microsoft edge v 17.17134 displays a # on postback

I recently stumbled upon a weird problem with the last version of Microsoft Edge (17.17134).
I have a really simple classic asp form that posts data to another asp form. If I post a string which contains
input
and
onclick=""
the receiving page will only display a "#" even if the code behind seems ok(see screenshot)
here's a snippet:
<!doctype html>
<html>
<body>
<form method="POST" action="to.asp">
<input type="text" name="hidInnerHTML" id="hidInnerHTML" style="width:500px;" value="steve would like your input on what to do when you activate the onclick= method" />
<br />
<input type="submit" value="click me"/>
</form>
</body>
</html>
and here is the code at the receiving end:
<!doctype html>
<html>
<body>
<div style="border:1px solid red;"></div>
</body>
</html>
It seems that certain keyword in the post data will trigger this effect. IE, chrome, probably Firefox, previous version of edge - all work correctly.
Any clues or idea what is happening here?
I'll take all the help I can get! :)
After doing a bit more research, i can see that this exact issue has just been raised here...
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/19045578/
Check out the link for a fuller explanation but the short story is that you either set a "X-XSS-Protection" response header on your site with a value of "0" or you wait for the Windows 10 Insider Preview version (Build 17758) of Edge which includes the fix for this bug.
Microsoft Edge 44.17758.1.0
Microsoft EdgeHTML 18.17758

JQuerymobile textbox and button on sameline

http://view.jquerymobile.com/1.4.0/demos/controlgroup/#Textinputs
I followed the above link from jquery mobile. It doesn't work as expected !
Can someone help
Try setting the height too:
<div data-role="controlgroup" data-type="horizontal">
<input type="text" id="search-control-group" data-wrapper-class="controlgroup-textinput ui-btn">
<button>Submit</button>
</div>
.controlgroup-textinput{
height: 20px;
    padding-top:.22em;
    padding-bottom:.22em;
}
DEMO
To anyone having the same issue after using the code from the jquerymobile demos!
If you copy html or css content from the demos page, make sure to remove all leading whitespaces (indentation) first and add your own!
The demos page uses some other invisible non breakable spaces that prevent proper css parsing in most browsers!
I had the same issue and when looking into the css parsed by chrome it was marking
" padding-top: .22em;"
as invalid css, because of those non breakable spaces.

When is the Scan Credit Card option available on iOS8 Safari?

So Safari offers Scan Credit Card feature on iOS8 with some credit card forms.
My question is, how does Safari determine when to offer this option?
So far I found that this option is available on Amazon and PayPal, but none of my credit card input forms were able to reproduce this behaviour.
After a bit of research with an iOS8 browser and Chrome emulation I figured it out partially. I know of some solutions, but I don't know for sure if there are other ways to do it. You'll have to thank Apple for the amazing lack of documentation around this.
Currently Netflix/Amazon have credit card scanning working properly. So I emulated an iOS8 user agent in my Chrome browser and inspected the markup of their credit card number field. Here's Netflix's:
<input name="cardNumber" smopname="num" id="cardNumber-CC" class="cardNumber" type="text" value="************0891" pattern="[0-9]*">
And here's Amazon's:
<input name="addCreditCardNumber" size="20" maxlength="20">
At that point I played around with a form served over HTTPS that I had control over and started setting attributes to see what would happen. Below, "works" means "successfully triggered card scan" and "doesn't work" means "did not trigger card scan":
name="addCreditCardNumber" => works
name="cardNumber" => works
name="cardnumber" => works
class="cardNumber" => does not work
type="cardNumber" => does not work
id="cardNumber", id="creditCardNumber", id="creditCardMonth", id="creditCardYear" => works
Since the name attribute drives form data and might impact the way server-side form processing works I highly recommend triggering credit card scan by setting your input id to cardNumber.
I would link to the relevant documentation...but hey! There's none (at least, not that I know of)
I think your better bet is to use HTML5 Autocomplete Types on your inputs.
Stick to the credit card related types, and most modern browsers will auto recognize these fields for you, including Mobile Safari and the "Scan Credit Card" feature. Bonus is that you'll always get the correct keyboard on mobile devices too.
Example (note autocomplete, x-autocompletetype, and pattern attributes):
<input type="text" id="cc-num" autocomplete="cc-number" x-autocompletetype="cc-number" pattern="\d*">
<input type="text" id="cc-name" autocomplete="cc-name" x-autocompletetype="cc-full-name">
I also wrote a related blog post on this topic and built an HTML5 Autocomplete Cheatsheet.
In addition to Arnaud Brousseau's answer, a search for "card number" in the iOS simulator files yields this file:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/SafariShared.framework/SafariShared
A quick run of strings on it reveals these strings which are certainly used for matching potential fields:
card number
cardnumber
cardnum
ccnum
ccnumber
cc num
creditcardnumber
credit card number
newcreditcardnumber
new credit card
creditcardno
credit card no
card#
card #
cvc2
cvv2
ccv2
security code
card verification
name on credit card
name on card
nameoncard
cardholder
card holder
name des karteninhabers
card type
cardtype
cc type
cctype
payment type
expiration date
expirationdate
expdate
and a bit further:
month
date m
date mo
year
date y
date yr
Can't quite see (with this naïve approach) any references to which attributes (id, name, placeholder...) or other metadata (label maybe?) are actually compared against this list. Also, with the exception of "name des karteninhabers", this is really very english-oriented, that's quite unusual for Apple IMHO.
Thanks to #barbazoo, the Scan Credit Card option will be available over https with a valid (not self signed) certificate.
For the expiration fields, based on Arnaud's answer, I found that the expiration fields would be recognized from cardExpirationYear and cardExpirationMonth being in the id attribute.
This worked when the year and month are regular text inputs with the appropriate IDs. The month is populated as a 2-digit number and the year as a 4-digit number.
In a quick test using <select> tags, I found that it also populated the correct month and year.
<input type="text" id="cardNumber" placeholder="CC number">
<select id="cardExpirationMonth">
<option value="01">01</option>
<option value="02">02</option>
...
<option value="11">11</option>
<option value="12">12</option>
</select>
<select id="cardExpirationYear">
<option value="2014">2014</option>
<option value="2015">2015</option>
...
<option value="2024">2024</option>
<option value="2025">2025</option>
</select>
I don't know what other values will work in the option tags.
It's not about when, it's about how we can enable this feature in Safari browser.
Let's just talk about what happens when a form is submitted:
Some browsers stores all input values with it's name attribute. And it will offer to autocomplete those fields when it encounters same named input elements.
Some browsers scan for just autocomplete attribute for offering auto-completion and,
Some others scan for an attribute like label or name for input elements too.
Now, autocomplete attribute can have a larger set of values including cc-name (Card name), cc-number, cc-exp, cc-csc (Security number - CVV) etc. (full list here)
For example, we could say to a browser that, this is card number field and it should offer autocomplete when possible and it should enable scan credit card feature as:
<label>Credit card number:
<input type=text autocomplete="cc-number">
</label>
In general:
<input type="text" autocomplete="[section-](optional) [shipping|billing](optional)
[home|work|mobile|fax|pager](optional) [autofill field name]">
more detailed ex:
<input type="text" name="foo" id="foo" autocomplete="section-red shipping mobile tel">
And each autocomplete values goes like this:
section-red : wrapping as a section. (named red)
shipping : shopping/billing
mobile : home|work|mobile|fax|pager (For telephone)
tel : [Tokens][2]
When we code it like this browser know exactly what kind of value should be populated in that field.
But browser like safari need name or id or label values should also be set right.
Support so far for autocomplete, id and name attributes for auto-completing values.
Browse Ver OS ID Name Autocomplete
Chrome 50 OS X 10.11.4 No Yes Yes
Opera 35 OS X 10.11.4 No Yes Yes
Firefox 46 OS X 10.11.4 Yes Yes No
Edge 25 Windows 10 No Yes No
Safari 9.1 OS X 10.11.4 Partial Partial Partial
Safari 9 iOS 9.3.1 Partial Partial Partial
There are more things at play here. I strongly recommend this blog I referred.
I've found that something like this works, but I consider this a very ugly solution, since it depends on the actual displayed text between the label tags:
<html>
<head>
<title>AutoFill test</title>
</head>
<body>
<h1>AutoFill test</h1>
<h2>revision 4</h2>
<form action="#">
<input type="text" name="cardNumber" id="id1"> <label for="id1">Number</label><br>
<input type="text" name="cardName" id="id2"> <label for="id2">Name on card</label><br>
<label>Expiration date</label>
<input type="text" name="expirationMonth" id="id3" maxlength="2">
<input type="text" name="expirationYear" id="id4" maxlength="2"><br>
<input type="text" name="csc" id="5"> <label for="id5">CSC</label><br>
</form>
</body>
</html>
I am not entirely sure, but I think, that name parameters are not important.
This is now all broken after upgrading to iOS 8.1.3 this morning. When on iOS 8.1.2 all of the above worked just fine - now the keyboard option to scan credit card simply does not appear. Here's my code, which did work yesterday on iOS 8.1.2 and does not work today on iOS 8.1.3:
<html>
<head>
<title>Scan credit card using iOS 8</title>
<style type="text/css">
input {height:1.5em;width:95%}
input[type="number"] {font-size: 2.5em}
body {background-color:lightgray;font-size: 3em;font-family: sans-serif;}
#purchase {font-size: 2em;font-weight: bold;height:1.2em}
</style>
</head>
<body>
<form action="https://yoursite.com/credit-card-purchase" method="POST">
Credit Card Number 1<br />
<input type="number" autocomplete="cc-number" name="cardNumber" id="cardNumber" value="" placeholder="*** **** *** ****" />
<br />
Expiry month <br />
<input type="number" name="expirationMonth" id="cardExpirationMonth" />
<br />
Expiry year <br />
<input type="number" name="expirationYear" id="cardExpirationYear" />
<br />
<br />
<input type="submit" value="Purchase" id="purchase">
</form>
</head>
</html>
Even after using the autocomplete and ID methods described above, I had a label at the top of my page with the value Credit / Debit / Gift Card that prevented iOS from offering the Scan CC option. I ended up adding this label above my CC number field to trick iOS into offering the Scan CC option:
<label style="opacity:0.01;color:#FFF;font-size:2pt;">Card Number</label>
Opacity of 0, or a font-size of 1pt prevents iOS from offering the option.

Getting onClick to work on iPad Safari

I just inherited a website and haven't worked on website for about 15 years and am not familiar with programing for touch screens.
I have the below onClick submit code that works on all browsers (including Safari desktop on PC) that I have tested as well as using Google search on an iPad, but when attempting to press the "Submit" button when accessing the site via iPad Safari it will not fire. I've search for JQuery solutions, but am not up to speed on JQuery. Any help appreciated.
function submitentry()
{
password = document.password1.password2.value.toLowerCase()
username = document.password1.username2.value.toLowerCase()
passcode = 1
usercode = 1
for(i = 0; i
<center>
<form action="" name="password1">
<strong>User * * : </strong>
<input type="text" name="username2" size="15">
<br>
<strong>Password: </strong>
<input type="password" name="password2" size="15">
<br><br>
<input type="button" value="Submit"onClick="submitentry(); return true">
</form>
Turns out that any non-anchor element assigned a click handler in jQuery must either have an onClick attribute (can be empty like below):
onClick=""
OR
The element css needs to have the following declaration:
cursor:pointer
via : http://www.mitch-solutions.com/blog/17-ipad-jquery-live-click-events-not-working
I'm not sure but that's probably because touch devices doesn't have pointer.
Try .live():
$(document).ready(function(){
$("#submitButton").live("click", function(){
// do something
}
});
Or, try this plugin:
https://github.com/aanand/jquery.tappable.js
I suggest you to try to avoid writing unobtrusive code such inline event handlers like onclick, onmousedown, etc because different browser work differently. Especially in touch devices.
Thanks for the suggestion. Being new to jQuery it is taking me awhile to get up to speed. Below is what I got to work, so far, but still am having problems with the touch screen on iPad when accessing the site using Safari. But it does work, strangely, when I access the site using Google on the iPad. Strange, I think!
My HTML input statement is:
<input type="button" value="Submit" id="click"/>
jQuery:
$('#click') .click(function(){
submitentry();
});
I'm thinking that if I use something other than .click it might work. Just need to figure out what. We'll see...

Knockout Javascript any strategies for making a foreach checkbox section with a bound observable array

Basically I'm making a repeatable section and I want to have the checked state of all checkboxes pre-supplied by an array.
<div style="height: 100%; border: 1px solid grey; overflow-y: scroll;" id="AssociatedUsers" data-bind="foreach: AllUserList">
<input type='checkbox' class='cSupUser' style="width:20px;margin:2px" value="$data" data-bind='checked: supplierUsers' /><span data-bind='text: $data.Text'></span><br />
</div>
But obviously value="$data" is just returning the string "$data". I've decided to start working on a solution where I just map the array with json strings when I save and load the related data, but this adds complication and feels like a hack, so I was wondering if there is a better way to handle this situation. I would also prefer supplierUsers could just be mapped directly to the viewModel, because I'm going to be generating the response to the server from the viewModel, but it seems like observableArrays don't work for that parameter.
I'm only 3 days into using knockout framework, any help/suggestions are appreciated.
The way i've dealt with this is to use the attr binding for each checkbox. E.G.
<input type="checkbox" data-bind="checked : supplierUsers, attr : { value : $data}" />

Resources