javascript

Hagi 2012. 6. 10. 12:24

참고 :   http://blog.naver.com/PostView.nhn?blogId=lazyker&logNo=110132151415

=> input만 허용시 여기 참조 



 <script type="text/javascript">
//뒤로 가기 등의 키 방지용
document.onkeydown = function (e) {
key = (e) ? e.keyCode : event.keyCode;

if (key == 8 || key == 116) {
if (event.srcElement.type != "text" && event.srcElement.type != "textarea") {
if (e) { //표준
e.preventDefault();
}
else { //익스용
event.keyCode = 0;
event.returnValue = false;
}
}
}
}
//뒤로 가기 버튼 시 데이터 손실 방지용
function noBack() { window.history.forward() }
noBack();
window.onload = noBack;
window.onpageshow = function (evt) { if (evt.persisted) noBack() }
window.onunload = function () { void (0) }
 </script>



 
 
 

javascript

Hagi 2012. 6. 5. 18:01

// This adds placeholder support to browsers that wouldn't otherwise support it.
$(function () {
if (!$.support.placeholder) {
var active = document.activeElement;
$(':text').focus(function () {
if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
$(this).val('').removeClass('hasPlaceholder');
}
}).blur(function () {
if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
}
});
$(':text').blur();
$(active).focus();
$('form:eq(0)').submit(function () {
$(':text.hasPlaceholder').val('');
});
}
});


또 다른 형식의 script 

// 입력값 안내문 설정
function inputvalueAttribute(element, attribute) {
var inputvalue = document.createElement(element);
if (attribute in inputvalue)
return true;
else
return false;
}
if (!inputvalueAttribute("input", "placeholder")) {
window.onload = function () {
    //쿠폰 번호 입력값 설정
var couponno = document.getElementById("<%=couponno.ClientID %>");
var couponno_content = "CP- XXXX-XXXX-XXXX-XXXX";

couponno.style.color = "gray";
couponno.value = couponno_content;

couponno.onfocus = function () {
if (this.style.color == "gray")
{ this.value = ""; this.style.color = "black" }
}
couponno.onblur = function () {
if (this.value == "")
{ this.style.color = "gray"; this.value = couponno_content; }
}
}
}

 
 
 

javascript

Hagi 2012. 6. 5. 13:46

// cvv sample display control
function showCVVSample() {
document.getElementById('cvv_sample_disp').style.display = "";
}
document.onclick = function (e) {
var target = (e) ? e.target : window.event.srcElement;
if (target.id != 'cvv_sample_disp' && target.id != 'cvv_sample_link') {
hideCVVSample();
}
}
function hideCVVSample() {
document.getElementById('cvv_sample_disp').style.display = 'none';
}


------------------------------------------------------------------------


<div class="credit_card_code"><a href="#" onclick="showCVVSample()" id="cvv_sample_link">What is this?</a></div>
<div class="credit_card_code_info" id="cvv_sample_disp" style="display:none">Where to find your Security Code? Visa / MasterCard</div>


-------------------------------------------------------------------------------

.credit_card_code {
width: 70px;
height: auto;
position: relative;
top: -40px;
left: 340px;
font-family: "MyriadProRegular";
font-size: 12px;
font-weight: 400;
 color: #999999;
}


.credit_card_code_info {
width: 149px;
height: 228px;
float: left;
position: relative;
top: -40px;
left: 340px;
font-family: "MyriadProRegular";
font-size: 12px;
font-weight: 400;
color: #999999;
background: url(../image/credit_card_code.png) top center no-repeat;
padding-top: 15px;
padding-left: 13px;
line-height: 15px;
}


참고 :  http://tweb.tistory.com/entry/%EC%97%AC%EB%B0%B1%EB%B0%94%ED%83%95-%ED%81%B4%EB%A6%AD%EC%8B%9C-%EB%A0%88%EC%9D%B4%EC%96%B4-%EC%82%AC%EB%9D%BC%EC%A7%80%EA%B2%8C-%ED%95%98%EA%B8%B0