Created
August 6, 2011 19:42
-
-
Save dciccale/1129678 to your computer and use it in GitHub Desktop.
Extend jQuery form selectors expressions with HTML5 input types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.extend(jQuery.expr[':'], { | |
email: function(a) { | |
return a.type&&a.type=='email'; | |
}, | |
url: function(a) { | |
return a.type&&a.type=='url'; | |
}, | |
search: function(a) { | |
return a.type&&a.type=='search'; | |
}, | |
tel: function(a) { | |
return a.type&&a.type=='tel'; | |
}, | |
datetime: function(a) { | |
return a.type&&a.type=='datetime'; | |
}, | |
date: function(a) { | |
return a.type&&a.type=='date'; | |
}, | |
month: function(a) { | |
return a.type&&a.type=='month'; | |
}, | |
week: function(a) { | |
return a.type&&a.type=='week'; | |
}, | |
time: function(a) { | |
return a.type&&a.type=='time'; | |
}, | |
datetimelocal: function(a) { | |
return a.type&&a.type=='datetime-local'; | |
}, | |
number: function(a) { | |
return a.type&&a.type=='number'; | |
}, | |
range: function(a) { | |
return a.type&&a.type=='range'; | |
}, | |
color: function(a) { | |
return a.type&&a.type=='color'; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
** IMPORTANT ** | |
This will only work on modern browsers that supports these new input types, if not they will be treated as "text" types. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment