-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.js
31 lines (25 loc) · 827 Bytes
/
common.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// JavaScript Document
(function($) {
$(document).ready(function(){
// utility function add, remove
function add() {
if($(this).val() == ''){
$(this).val($(this).attr('placeholder')).css('color', 'gray');
}
}
function remove() {
if($(this).val() == $(this).attr('placeholder')){
$(this).val('');
}
}
// Detect if placeholder is not supported
if (!('placeholder' in $('<input>')[0])) {
// Select the elements that have a placeholder attribute
$('input[placeholder]').blur(add).focus(remove).each(add);
// Remove the placeholder text before the form is submitted
$('form').submit(function(){
$(this).find('input[placeholder]').each(remove);
});
}
});
})(jQuery);