🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.javascript
8 messages
8 total messages Started by Peter May Tue, 21 Dec 2010 13:06
Test html5 i input type date
#50435
Author: Peter May
Date: Tue, 21 Dec 2010 13:06
22 lines
1302 bytes
Sprawdzam, czy przeglądarka obsługuje właściwość "date" dla "input"-a tak:

	var elm = document.createElement("input");
	elm.setAttribute("type", "date");
	
	if(elm['type'] != "text")
	{
		return true;
	}
	return false;

To pokazuje mi, że Chrome 8.0.552.224 obsługuje input type date. Ale z 
kolei tutaj widzę:

http://miketaylr.com/code/html5-forms-ui-support.html

że nie Chrome nie obsługuje input type date.

Ja mam błąd w kodzie? Czy w powyższym URL-u test jest nieprawidłowy?

-- 
Peter
Re: Test html5 i input type date
#50436
Author: Paweł Piskorz
Date: Tue, 21 Dec 2010 15:34
35 lines
1885 bytes
On 2010-12-21 14:06, Peter May wrote:
> Sprawdzam, czy przeglądarka obsługuje właściwość "date" dla "input"-a tak:
>
> var elm = document.createElement("input");
> elm.setAttribute("type", "date");
>
> if(elm['type'] != "text")
> {
> return true;
> }
> return false;
>
> To pokazuje mi, że Chrome 8.0.552.224 obsługuje input type date.

GChrome tak obsługuje input[type=date] jak GMail pisanie pod cytatem.

> Ale z kolei tutaj widzę:
>
> http://miketaylr.com/code/html5-forms-ui-support.html
>
> że nie Chrome nie obsługuje input type date.
>
> Ja mam błąd w kodzie? Czy w powyższym URL-u test jest nieprawidłowy?

http://www.w3.org/TR/html5/states-of-the-type-attribute.html#date-state
"User agents must not allow the user to set the value to a string that 
is not a valid date string."
Jaka "data" widnieje w polach daty w GChrome "obsługującym" 
input[type=date]?


-- 
message[autor="PablO"]::after {
	content:"Pozdrawiam";
}
Re: Test html5 i input type date
#50437
Author: Peter May
Date: Tue, 21 Dec 2010 18:05
38 lines
2012 bytes
W dniu 2010-12-21 16:34, Paweł Piskorz pisze:
> On 2010-12-21 14:06, Peter May wrote:
>> Sprawdzam, czy przeglądarka obsługuje właściwość "date" dla "input"-a
>> tak:
>>
>> var elm = document.createElement("input");
>> elm.setAttribute("type", "date");
>>
>> if(elm['type'] != "text")
>> {
>> return true;
>> }
>> return false;
>>
>> To pokazuje mi, że Chrome 8.0.552.224 obsługuje input type date.
>
> GChrome tak obsługuje input[type=date] jak GMail pisanie pod cytatem.

No też mi się tak zdaje :-)

>> Ale z kolei tutaj widzę:
>>
>> http://miketaylr.com/code/html5-forms-ui-support.html
>>
>> że nie Chrome nie obsługuje input type date.
>>
>> Ja mam błąd w kodzie? Czy w powyższym URL-u test jest nieprawidłowy?
>
> http://www.w3.org/TR/html5/states-of-the-type-attribute.html#date-state
> "User agents must not allow the user to set the value to a string that
> is not a valid date string."
> Jaka "data" widnieje w polach daty w GChrome "obsługującym"
> input[type=date]?

No np. 275760-09-13. Zastanawiałem się co to za dziwny format. Hm...

-- 
Peter
Re: Test html5 i input type date
#50438
Author: Peter May
Date: Tue, 21 Dec 2010 18:10
17 lines
1614 bytes
W dniu 2010-12-21 16:34, Paweł Piskorz pisze:
> http://www.w3.org/TR/html5/states-of-the-type-attribute.html#date-state
> "User agents must not allow the user to set the value to a string that
> is not a valid date string."
> Jaka "data" widnieje w polach daty w GChrome "obsługującym"
> input[type=date]?

String w postaci daty może mieć różne formaty. Mnie interesuje 
DD-MM-YYYY. Ale to można sobie łatwo sprawdzić czy wprowadzana data jest 
w wymaganym przez siebie formacie.

Nie zmienia to faktu, iż testując właściwość atrybutu dostaję informację 
zwrotną, iż GChrome obsługuje input type date. A zatem obsługuje, ale 
błędnie. Chyba, że ja coś źle testuję :/

-- 
Peter
Re: Test html5 i input type date
#50439
Author: porneL
Date: Tue, 21 Dec 2010 20:41
36 lines
1969 bytes
On Tue, 21 Dec 2010 13:06:34 -0000, Peter May <peter.may@onet.pl> wrote:

> Sprawdzam, czy przeglądarka obsługuje właściwość "date" dla "input"-a  
> tak:
> 	var elm = document.createElement("input");
> 	elm.setAttribute("type", "date");
> 	
> 	if(elm['type'] != "text")
> 	{
> 		return true;
> 	}
> 	return false;
>
> To pokazuje mi, że Chrome 8.0.552.224 obsługuje input type date. Ale z  
> kolei tutaj widzę:
>
> http://miketaylr.com/code/html5-forms-ui-support.html
>
> że nie Chrome nie obsługuje input type date.
>
> Ja mam błąd w kodzie? Czy w powyższym URL-u test jest nieprawidłowy?

Kod jest ok. Niestety implementacja jest bylejaka w WebKit. W poprzedniej  
wersji podobnie dali ciała z "obsługą" type=email, gdzie zaimplementowali  
walidację, ale nie zaimplementowali dla niej żadnego UI — źle wpisany  
formularz powodował ciche ignorowanie submit i nic poza tym.

Mam wrażenie, że bardziej interesuje ich zaliczanie punktów na  
html5test.com, niż używalna implementacja…

Nie widzę innego wyjścia, niż dodanie "bana" na user-agent Chrome < 11  
(albo odpowiednią wersję WebKit).

-- 
http://pornel.net
this.author = new Geek("porneL");
Re: Test html5 i input type date
#50440
Author: Peter May
Date: Tue, 21 Dec 2010 22:28
42 lines
2347 bytes
W dniu 2010-12-21 21:41, porneL pisze:
> On Tue, 21 Dec 2010 13:06:34 -0000, Peter May <peter.may@onet.pl> wrote:
>
>> Sprawdzam, czy przeglądarka obsługuje właściwość "date" dla "input"-a
>> tak:
>> var elm = document.createElement("input");
>> elm.setAttribute("type", "date");
>>
>> if(elm['type'] != "text")
>> {
>> return true;
>> }
>> return false;
>>
>> To pokazuje mi, że Chrome 8.0.552.224 obsługuje input type date. Ale z
>> kolei tutaj widzę:
>>
>> http://miketaylr.com/code/html5-forms-ui-support.html
>>
>> że nie Chrome nie obsługuje input type date.
>>
>> Ja mam błąd w kodzie? Czy w powyższym URL-u test jest nieprawidłowy?
>
> Kod jest ok. Niestety implementacja jest bylejaka w WebKit. W
> poprzedniej wersji podobnie dali ciała z "obsługą" type=email, gdzie
> zaimplementowali walidację, ale nie zaimplementowali dla niej żadnego UI
> — źle wpisany formularz powodował ciche ignorowanie submit i nic poza tym.

A, to dlatego jakieś dziwne strzałki pojawiają się, których sens nie 
mogłem zrozumieć.

> Mam wrażenie, że bardziej interesuje ich zaliczanie punktów na
> html5test.com, niż używalna implementacja…
>
> Nie widzę innego wyjścia, niż dodanie "bana" na user-agent Chrome < 11
> (albo odpowiednią wersję WebKit).

Argh... nie lubię coś ukrywać używając browser sniffing :/ Ale w tym 
przypadku nie ma wyjścia.

-- 
Peter
Re: Test html5 i input type date
#50441
Author: Gadjo Delhi
Date: Fri, 24 Dec 2010 01:28
8 lines
1581 bytes
> Argh... nie lubię coś ukrywać używając browser sniffing :/ Ale w tym
> przypadku nie ma wyjścia.

var el = document.createElement('input');
el.type = 'date';
el.value = 'dupa';
if (el.type !== 'date' || el.value === 'dupa') alert('nie obsluguje');
else alert('obsługuje');
Re: Test html5 i input type date
#50442
Author: Peter May
Date: Fri, 24 Dec 2010 10:33
20 lines
1679 bytes
W dniu 2010-12-24 02:28, Gadjo Delhi pisze:
>> Argh... nie lubię coś ukrywać używając browser sniffing :/ Ale w tym
>> przypadku nie ma wyjścia.
>
> var el = document.createElement('input');
> el.type = 'date';
> el.value = 'dupa';
> if (el.type !== 'date' || el.value === 'dupa') alert('nie obsluguje');
> else alert('obsługuje');

Faktycznie w Chrome powyższe daje false; Kluczem jest tu value, które 
ustawione w powyższy sposób nie spełnia warunków dla poprawności formatu 
daty:

http://dev.w3.org/html5/spec-author-view/common-microsyntaxes.html#valid-date-string

Dzięki za podpowiedź.

-- 
Peter
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads