var uploadFile1 = $('#uploadFile1').val();


var FileFilter = /\.(jpg|gif)$/i;

var extArray = new Array(".jpg", ".gif");   



if(uploadFile1 != ''){

if (!uploadFile1.match(FileFilter)){

alert("다음 파일만 업로드가 가능합니다.\n\n"  + (extArray.join("  ")) + "\n\n 업로드할 파일을 " + " 다시 선택하여 주세요.");

return false;

}

}

'Client Standard > JavaScript & jQuery' 카테고리의 다른 글

[Chart] FusionCharts 오픈 소스 API  (0) 2015.08.27
[Editor] Tiny  (0) 2014.12.29
[프린트] window.print()  (0) 2014.09.12
[Js] 모바일, 웹 브라우저 체크  (0) 2014.08.25
[API] jQuery select box  (0) 2014.08.22

퍼블리셔 : 미리보기 자체는 엄밀히 말하면 이중적 오류

window.print() 함수를 쓰며 -> 미리보기 + print 기능이 native로 제공된다.


참고 url

http://ggoreb.tistory.com/178 


'Client Standard > JavaScript & jQuery' 카테고리의 다른 글

[Editor] Tiny  (0) 2014.12.29
[validation] 파일업로드 체크  (0) 2014.09.17
[Js] 모바일, 웹 브라우저 체크  (0) 2014.08.25
[API] jQuery select box  (0) 2014.08.22
[jQuery] 이메일 창 활성화 / 비활성화  (0) 2014.05.30


navigator.userAgent



브라우저 userAgent 값들
iPhone, iPod, BlackBerry, Android, Windows CE, LG, MOT, SAMSUNG, SonyEricsson



<script type="text/javascript">
var mobileKeyWords = new Array('iPhone', 'iPod', 'BlackBerry', 'Android', 'Windows CE', 'LG', 'MOT', 'SAMSUNG', 'SonyEricsson');
for (var word in mobileKeyWords){
    if (navigator.userAgent.match(mobileKeyWords[word]) != null){
        location.href = "보내고 싶은 모바일 경로";
        break;
    }
}
</script>

'Client Standard > JavaScript & jQuery' 카테고리의 다른 글

[validation] 파일업로드 체크  (0) 2014.09.17
[프린트] window.print()  (0) 2014.09.12
[API] jQuery select box  (0) 2014.08.22
[jQuery] 이메일 창 활성화 / 비활성화  (0) 2014.05.30
[Mobile] 체크하기  (0) 2014.03.07

■ jQuery select box 관련 api

111


// select box ID로 접근하여 선택된 값 읽기

$("#셀렉트박스ID option:selected").val();


// select box Name로 접근하여 선택된 값 읽기

$("select[name=셀렉트박스name]").val();


// 같은 방식으로 span과 같은 다른 태그도 접근 가능하다~

$("span[name=셀렉트박스name]").text();


// 선택된 값의 index를 불러오기

var index = $("#셀렉트박스ID option").index($("#셀렉트박스ID option:selected"));


// 셀렉트 박스에 option값 추가하기

$("#셀렉트박스ID").append("<option value='1'>1번</option>");


// 셀렉트 박스 option의 맨앞에 추가 할 경우

$("#셀렉트박스ID").prepend("<option value='0'>0번</option>");


// 셀렉트 박스의 html 전체를 변경할 경우

$("#셀렉트박스ID").html("<option value='1'>1차</option><option value='2'>2차</option>");


// 셀렉트 박스의 index별로 replace를 할 경우

// 해당 객체를 가져오게 되면, option이 다수가 되므로 배열 객체가 되어 eq에 index를 넣어 개별 개체를 선택할 수 있다.

$("#셀렉트박스ID option:eq(1)").replaceWith("<option value='1'>1차</option>");


// 직접 index 값을 주어 selected 속성 주기

$("#셀렉트ID option:eq(1)").attr("selected", "selected");


// text 값으로 selected 속성 주기

$("#셀렉트ID")val("1번").attr("selected", "selected");


// value 값으로 selected 속성 주기

$("#셀렉트ID").val("1");


// 해당 index item 삭제하기

$("#셀렉트ID option:eq(0)").remove();


// 첫번째, 마지막 item 삭제하기

$("#셀렉트ID option:first").remove();

$("#셀렉트ID option:last").remove();


// 선택된 옵션의 text, value 구하기

$("#셀렉트ID option:selected").text();

$("#셀렉트ID option:selected").val();


// 선택된 옵션의 index 구하기

$("#셀렉트ID option").index($("#셀렉트ID option:selected"));


// 셀렉트박스의 아이템 갯수 구하기

$("#셀렉트ID option").size();


// 선택된 옵션 전까지의 item 갯수 구하기

$("#셀렉트ID option:selected").prevAll().size();


// 선택된 옵션 후의 item 갯수 구하기

$("#셀렉트ID option:selected").nextAll().size();


 // 해당 index item 이후에 option item 추가 하기

$("#셀렉트ID option:eq(0)").after("<option value='3'>3번</option>");


// 해당 index item 전에 option item 추가하기

$("#셀렉트ID option:eq(3)").before("<option value='2'>2번</option>");


// 해당 셀렉트 박스에 change event binding 하기

$("#selectID").change(function() {

alert($(this).val());

alert($(this).children("option:selected").text());

});



$('#chargeEmail3').change(function(){

$('#chargeEmail3 option:selected').each(function() {

if($(this).val() == 'self'){

$('#chargeEmail2').val('');

$('#chargeEmail2').attr("disabled", false);

} else if ($(this).val == 'select'){

$('#chargeEmail2').val('');

$('#chargeEmail2').attr("disabled", false);

} else {

$('#chargeEmail2').val($(this).text());

$('#chargeEmail2').attr("disabled", true);

}

});

});



<tr>

<th scope="row"><label for="chargeEmail">담당자  이메일</label></th>

<td>

<div class="item">

<input type="text" id="chargeEmail" name="chargeEmail" class="in_text" style="width:100px;" value="" maxlength="20" title="이메일 아이디" /> @

<input type="text" id="chargeEmail2" name="chargeEmail2" class="in_text" style="width:100px;" value="" maxlength="20" title="이메일 아이디" />

<select name="chargeEmail3" id="chargeEmail3" title="직접선택" style="width:160px;">

<option value="self">직접입력</option>

<option value="naver.com">naver.com</option>

<option value="hanmail.net">hanmail.net</option>

<option value="nate.com">nate.com</option>

<option value="daum.net">daum.net</option>

<option value="paran.com">paran.com</option>

<option value="gmail.com">gmail.com</option>

<option value="hotmail.com">hotmail.com</option>

<option value="yahoo.co.kr">yahoo.co.kr</option>

<option value="empal.com">empal.com</option>

<option value="lycos.co.kr">lycos.co.kr</option>

<option value="korea.com">korea.com</option>

<option value="dreamwiz.com">dreamwiz.com</option>

<option value="freechal.com">freechal.com</option>

</select>

</div>

</td>

</tr>

if (navigator.userAgent.match(/iPad/) == null && navigator.userAgent.match(/iPhone|Mobile|UP.Browser|Android|BlackBerry|Windows CE|Nokia|webOS|Opera Mini|SonyEricsson|opera mobi|Windows Phone|IEMobile|POLARIS/) != null){

location.href = "/m_index";

}

<script type="text/javascript">


$(document).ready(function() {

   //add more file components if Add is clicked

   $('#addFile').click(function() {

       var fileIndex = $('#tbodyContents tr td').children().length - 5;

       $('#tbodyContents').append(

               '<tr><th>file'+ fileIndex + '</th>' + 

               '<td class=\"td_left\"><input type=\"file\" name=\"files['+ (fileIndex -1) +']\" style=\"width:500px; height:16px; padding:2px 0 2px 2px;\" /></td>'+

               '</tr>');

   });

});

</script>





<table width="100%" border="0" cellspacing="0" summary="">

<caption></caption>

<colgroup>

<col width="20%" />

<col width="*" />

</colgroup>

<tbody id="tbodyContents">

<tr>

<th>제목</th>

<td class="td_left"><input id="subject" name="subject" type="text" style="width:500px; height:16px; padding:2px 0 2px 2px;"/></td>

</tr>

<tr>

<th>이미지 카테고리</th>

<td class="td_left"><input id="imgCategory" name="imgCategory" type="text" style="width:500px; height:16px; padding:2px 0 2px 2px;"/></td>

</tr>

<tr>

<th>키비쥬얼 순서</th>

<td class="td_left"><input id="keyVisual" name="keyVisual" type="text" style="width:500px; height:16px; padding:2px 0 2px 2px;"/></td>

</tr>

<tr>

<th>text1</th>

<td class="td_left"><input id="text1" name="text1" type="text" style="width:500px; height:16px; padding:2px 0 2px 2px;"/></td>

</tr>

<tr>

<th>text2</th>

<td class="td_left"><input id="text2" name="text2" type="text" style="width:500px; height:16px; padding:2px 0 2px 2px;"/></td>

</tr>

<tr>

<th>text3</th>

<td class="td_left"><input id="text3" name="text3" type="text" style="width:500px; height:16px; padding:2px 0 2px 2px;"/></td>

</tr>

<tr>

<th>file1</th>

<td class="td_left"><input name="files[0]" type="file"  style="width:500px; height:16px; padding:2px 0 2px 2px;"/></td>

</tr>

</tbody>

</table>

<script type="javascript">

$(".search input[type=text]").keypress(function(e) { 

    if (e.keyCode == 13){
        action();

    }    
});

</script> 

 

 

.search class명을 가진 엘리멘트 안에 input type이 text, 엔터(e.keyCode == 13)치면 함수호출


<input type="text" onkeypress="javascript:if(event.keyCode==13){goSearch();return false;}" />


프린트 팝업 페이지 에서,


$(document).ready(function(){

$('#contentArea').html($(opener.document).find("#content").html());

});

+ Recent posts