Recommendations
First of all, i would recommend your not to use placeholder.js
. There is no reason for using this. Implementing such a library will cause unnecessary overhead and traffic.
I also suggest you to check for functionality support instead of browsers and their versions! So I would also recommend you to get away from modernizr
and implement your own short check for functionality support.
Why should you do this? and
How to use this techniques bulletproof?
So, instead of implementing something like modernizr
, write your own little javascript class to check for support. You could do it like this:
window.Compatibility = {
Placeholder: function () {
return 'placeholder' in document.createElement('input');
}
};
Clean solution
In your case, check if the browser supports the placeholder attribute of input elements. If this is not the case, you can implement additional fallback logic:
window.Search = {
Placeholder: 'this is the default placeholder text',
Execute: function (pattern) {
// Implement your search logic here!
}
};
$('#executesearch').click(function() {
var searchpattern = $('#searchpattern').val();
if(!Compatibility.Placeholder){
if (searchpattern === Search.Placeholder)
return false;
}
Search.Execute(searchpattern);
}
I am assuming you have an <input id=searchpattern type=text>
where you can enter your search keywords and an <input id=executesearch type=button>
for executing the search.