<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<label for="from">From</label><input type="text" id="from" name="from">
<label for="to">to</label><input type="text" id="to" name="to">
<button class="btn" data-days="1">1일</button>
<button class="btn" data-days="3">3일</button>
<button class="btn" data-days="7">7일</button>
<button class="btn" data-days="15">15일</button>
<button class="btn" data-days="30">30일</button>
<script>
Date.prototype.formatYMD = function() {
return (this.getFullYear() + '-' + (this.getMonth() + 1) + '-' + this.getDate()).replace(/-(\d)(?=\D|$)/g, '-0$1');
};
$('#from').datepicker({
dateFormat: 'yy-mm-dd',
onSelect: function (selected) {
var dt = new Date(selected);
dt.setDate(dt.getDate() + 1);
$('#to').datepicker('option', 'minDate', dt);
}
});
$('#to').datepicker({ dateFormat: 'yy-mm-dd' });
$('.btn').on('click', function() {
var d = new Date($('#from').val());
d.setDate(d.getDate() + $(this).data('days'));
$('#to').val( d.formatYMD() );
});
</script>
</body>
</html>
http://shuai0.dothome.co.kr/demo/date.php
도메인 <input type="text" id="domain" value="">
서브도메인 <input type="text" id="subdomain" value="">
<script>
$('#domain').on('change', function() {
var arr = this.value.split('.');
$('#subdomain').val('');
// 2개 사용
last = 'com, net, org, biz, info,';
// #2 kr, cn 으로 끝나고 중간도메인이 해당되면 3개사용
kr_middle = 'co, ne, or, go, ac, pe, re, kg, es, ms, hs,';
cn_middle = 'com, net, org,';
if (arr[arr.length-1] == 'kr') {
if (kr_middle.indexOf(arr[arr.length-2] + ',') > -1)
cnt = 4;
else
cnt = 3;
} else if (last.indexOf(arr[arr.length-1] + ',') > -1) {
cnt = 3;
} else if (arr[length-1] == 'cn') {
if (cn_middle.indexOf(arr[arr.length-2] + ',') > -1)
cnt = 4;
else
cnt = 3;
} else
cnt = 4;
if (arr.length == cnt) $('#subdomain').val(arr[0]);
http://shuai0.dothome.co.kr/demo/subdomain.php
});
</script>