테스트 사이트 - 개발 중인 베타 버전입니다

js/placeholders.min.js 질문입니다. 채택완료

nickname123 7년 전 조회 2,547

 

placeholders.min.js 소스를 아래 소스로 바꿨습니다. 바꿨더니 제목을 입력안하면 동영상과 같이 초기화됩니다.

 

IE8에서 제목을 입력안하고 글등록을 하면 경고창이 뜬 뒤 여태까지 입력했던 내용이 다 사라집니다.

IE11과 크롬에서는 문제없이 잘 동작합니다.

 

뭐가 잘못된거죠? 수정하기 어려운건가요?

 

/* Placeholders.js v4.0.1 */ /*!  * The MIT License  *  * Copyright (c) 2012 James Allardice  *  * Permission is hereby granted, free of charge, to any person obtaining a copy  * of this software and associated documentation files (the "Software"), to  * deal in the Software without restriction, including without limitation the  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  * sell copies of the Software, and to permit persons to whom the Software is  * furnished to do so, subject to the following conditions:  *  * The above copyright notice and this permission notice shall be included in  * all copies or substantial portions of the Software.  *  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS  * IN THE SOFTWARE.  */ !function(a){"use strict";function b(){}function c(){try{return document.activeElement}catch(a){}}function d(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return!0;return!1}function e(a,b,c){return a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):void 0}function f(a,b){var c;a.createTextRange?(c=a.createTextRange(),c.move("character",b),c.select()):a.selectionStart&&(a.focus(),a.setSelectionRange(b,b))}function g(a,b){try{return a.type=b,!0}catch(c){return!1}}function h(a,b){if(a&&a.getAttribute(B))b(a);else for(var c,d=a?a.getElementsByTagName("input"):N,e=a?a.getElementsByTagName("textarea"):O,f=d?d.length:0,g=e?e.length:0,h=f+g,i=0;h>i;i++)c=f>i?d[i]:e[i-f],b(c)}function i(a){h(a,k)}function j(a){h(a,l)}function k(a,b){var c=!!b&&a.value!==b,d=a.value===a.getAttribute(B);if((c||d)&&"true"===a.getAttribute(C)){a.removeAttribute(C),a.value=a.value.replace(a.getAttribute(B),""),a.className=a.className.replace(A,"");var e=a.getAttribute(I);parseInt(e,10)>=0&&(a.setAttribute("maxLength",e),a.removeAttribute(I));var f=a.getAttribute(D);return f&&(a.type=f),!0}return!1}function l(a){var b=a.getAttribute(B);if(""===a.value&&b){a.setAttribute(C,"true"),a.value=b,a.className+=" "+z;var c=a.getAttribute(I);c||(a.setAttribute(I,a.maxLength),a.removeAttribute("maxLength"));var d=a.getAttribute(D);return d?a.type="text":"password"===a.type&&g(a,"text")&&a.setAttribute(D,"password"),!0}return!1}function m(a){return function(){P&&a.value===a.getAttribute(B)&&"true"===a.getAttribute(C)?f(a,0):k(a)}}function n(a){return function(){l(a)}}function o(a){return function(){i(a)}}function p(a){return function(b){return v=a.value,"true"===a.getAttribute(C)&&v===a.getAttribute(B)&&d(x,b.keyCode)?(b.preventDefault&&b.preventDefault(),!1):void 0}}function q(a){return function(){k(a,v),""===a.value&&(a.blur(),f(a,0))}}function r(a){return function(){a===c()&&a.value===a.getAttribute(B)&&"true"===a.getAttribute(C)&&f(a,0)}}function s(a){var b=a.form;b&&"string"==typeof b&&(b=document.getElementById(b),b.getAttribute(E)||(e(b,"submit",o(b)),b.setAttribute(E,"true"))),e(a,"focus",m(a)),e(a,"blur",n(a)),P&&(e(a,"keydown",p(a)),e(a,"keyup",q(a)),e(a,"click",r(a))),a.setAttribute(F,"true"),a.setAttribute(B,T),(P||a!==c())&&l(a)}var t=document.createElement("input"),u=void 0!==t.placeholder;if(a.Placeholders={nativeSupport:u,disable:u?b:i,enable:u?b:j},!u){var v,w=["text","search","url","tel","email","password","number","textarea"],x=[27,33,34,35,36,37,38,39,40,8,46],y="#ccc",z="placeholdersjs",A=new RegExp("(?:^|\\s)"+z+"(?!\\S)"),B="data-placeholder-value",C="data-placeholder-active",D="data-placeholder-type",E="data-placeholder-submit",F="data-placeholder-bound",G="data-placeholder-focus",H="data-placeholder-live",I="data-placeholder-maxlength",J=100,K=document.getElementsByTagName("head")[0],L=document.documentElement,M=a.Placeholders,N=document.getElementsByTagName("input"),O=document.getElementsByTagName("textarea"),P="false"===L.getAttribute(G),Q="false"!==L.getAttribute(H),R=document.createElement("style");R.type="text/css";var S=document.createTextNode("."+z+" {color:"+y+";}");R.styleSheet?R.styleSheet.cssText=S.nodeValue:R.appendChild(S),K.insertBefore(R,K.firstChild);for(var T,U,V=0,W=N.length+O.length;W>V;V++)U=Va;a++)U=a 이 소스를

 

    /* placeholder polyfill plugin */     /*! http://mths.be/placeholder" rel="nofollow noreferrer noopener" target="_blank">http://mths.be/placeholder v2.0.7 by @mathias */     (function(f,h,$){var a='placeholder' in h.createElement('input'),d='placeholder' in h.createElement('textarea'),i=$.fn,c=$.valHooks,k,j;if(a&&d){j=i.placeholder=function(){return this};j.input=j.textarea=true}else{j=i.placeholder=function(){var l=this;l.filter((a?'textarea':':input')+'[placeholder]').not('.placeholder').bind({'focus.placeholder':b,'blur.placeholder':e}).data('placeholder-enabled',true).trigger('blur.placeholder');return l};j.input=a;j.textarea=d;k={get:function(m){var l=$(m);return l.data('placeholder-enabled')&&l.hasClass('placeholder')?'':m.value},set:function(m,n){var l=$(m);if(!l.data('placeholder-enabled')){return m.value=n}if(n==''){m.value=n;if(m!=h.activeElement){e.call(m)}}else{if(l.hasClass('placeholder')){b.call(m,true,n)||(m.value=n)}else{m.value=n}}return l}};a||(c.input=k);d||(c.textarea=k);$(function(){$(h).delegate('form','submit.placeholder',function(){var l=$('.placeholder',this).each(b);setTimeout(function(){l.each(e)},10)})});$(f).bind('beforeunload.placeholder',function(){$('.placeholder').each(function(){this.value=''})})}function g(m){var l={},n=/^jQuery\d+$/;$.each(m.attributes,function(p,o){if(o.specified&&!n.test(o.name)){l[o.name]=o.value}});return l}function b(m,n){var l=this,o=$(l);if(l.value==o.attr('placeholder')&&o.hasClass('placeholder')){if(o.data('placeholder-password')){o=o.hide().next().show().attr('id',o.removeAttr('id').data('placeholder-id'));if(m===true){return o[0].value=n}o.focus()}else{l.value='';o.removeClass('placeholder');l==h.activeElement&&l.select()}}}function e(){var q,l=this,p=$(l),m=p,o=this.id;if(l.value==''){if(l.type=='password'){if(!p.data('placeholder-textinput')){try{q=p.clone().attr({type:'text'})}catch(n){q=$('').attr($.extend(g(this),{type:'text'}))}q.removeAttr('name').data({'placeholder-password':true,'placeholder-id':o}).bind('focus.placeholder',b);p.data({'placeholder-textinput':q,'placeholder-id':o}).before(q)}p=p.removeAttr('id').hide().prev().attr('id',o).show()}p.addClass('placeholder');p[0].value=p.attr('placeholder')}else{p.removeClass('placeholder')}}}(this,document,jQuery));

 

 

 

 

 

 

아래는 현재 만들고있는 write.skin.php 소스입니다.

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨 add_stylesheet('', 0);

add_javascript(G5_POSTCODE_JS, 0); //다음 주소 js // 주소입력 $wr4 = explode('|',$write['wr_4']); $ex_zip  = $wr4[0]; $ex_addr1  = $wr4[1]; $ex_addr2  = $wr4[2]; $ex_addr3  = $wr4[3]; $ex_jibeon  = $wr4[4]; ?>

< section id="bo_w">    

       

                                                '."\n".'';         }

        if ($is_html) {             if ($is_dhtml_editor) {                 $option_hidden .= '';             } else {                 $option .= "\n".''."\n".'';             }         }

        if ($is_secret) {             if ($is_admin || $is_secret==1) {                 $option .= "\n".''."\n".'';             } else {                 $option_hidden .= '';             }         }

        if ($is_mail) {             $option .= "\n".''."\n".'';         }     }

    echo $option_hidden;     ?>

       

                   
   

 

       

        옵션            
   

         

                       
                                                                       
                임시 저장된 글 목록                
                   
               
                       
               
        < img style="vertical-align:middle;" src="/../images/latesticon.jpg"> 기본정보       
                                                              class="frm_input " placeholder="비밀번호">        

                                               

    < div style="float:left;">  
    연락받으실 전화번호    
            - -   
    < /div>  
    FAX번호   
           - -    
     
    < /div> < div style="clear:both">
    < div style="margin-top:9px;">                                                                                 < /div>    
                   
                                       

    이 게시판은 최소 글자 이상, 최대 글자 이하까지 글을 쓰실 수 있습니다.

                                                               
    글자
                       
               

           

       

           

           
                                   
                           

                                                           

       

           

               
       

       

            취소            
       

            < /section>

    < !-- } 게시물 작성/수정 끝 -->

    댓글을 작성하려면 로그인이 필요합니다.

    답변 1개

    채택된 답변
    +20 포인트
    e
    7년 전

    아래의 소스를 function fwrite_submit(f) 함수내에 추가해보세요.

            if (!f.wr_subject.value {             alert("제목을 입력하세요.");             f.wr_subject.focus();             return false;         }

    로그인 후 평가할 수 있습니다

    답변에 대한 댓글 2개

    n
    nickname123
    7년 전
    답변 감사합니다;
    그런데
    function fwrite_submit(f)
    {

    if (!f.wr_subject.value) {
    alert("제목을 입력하세요.");
    f.wr_subject.focus();
    return false;
    }

    을 적용하고 ie8에서 테스트하면
    제목을 입력하세요 경고창이 뜬 후에 새로고침되어서 현재까지 입력했던 내용들이 다 삭제됩니다.;;
    e
    eyekiss
    7년 전
    return false; 이 부분이 새로고침 없이 원래 form 으로 돌아가는 건데요.
    안되신다면 잘 모르겠네요.
    url 과 ftp 가 있다면 이것저것 해볼텐데..^^;;

    댓글을 작성하려면 로그인이 필요합니다.

    답변을 작성하려면 로그인이 필요합니다.

    로그인