English 中文(简体)
Can the behaviour of new HTML5 form types be overridden?
原标题:

I was wondering if anyone knew if it were possible to override the default behaviour of browsers that support the new HTML input types such as type="email" and type="date"?

I appreciate that I could test if a browser supports an input type and provide a fallback for those browsers that don t, but what I want to know is is there any way to prevent that default behaviour from happening in browsers that do support it?

For instance, if in Opera I want to use the date input type, but I don t want Opera to display the native datepicker (i.e. I want to replace it with my own custom one) is that possible? Are there any DOM events triggered like onDatePickerShow that one can hook into?

I don t believe that this is possible, but if anyone knows for sure one way or the other I would love to hear from you.

最佳回答

input type=date without datepicker is almost the same as input type=text. If you want to keep validation, then you might use pattern attribute instead.

There s no way to customize look n feel of the standard date picker. There are no events for the picker. Spec doesn t define any UI for pickers. Consider how wildly different pickers can be – compare one you get on desktop with picker on the iPhone.

In the future CSS might get pseudo-classes for some customizations of date picker (and file picker), but currently it s all-or-nothing.

问题回答

Disable validation of HTML5 form elements

If you add a novalidate attribute, then for example you can enter an email without an @

This only seems to disable the client side HTML5 validation.





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签