javascript
  • jquery
  • css
  • asp.net
  • asp.net-mvc
  • 2014-05-11 4 views 3 likes 
    3

    NO file selected 텍스트를 제거하는 방법에 대한 많은 토론을 읽었습니다. 조건에 따라 파일을 선택하지 않음

    나는이 트릭이 일을 발견하지만 난 조금 다른 뭔가가 필요 : 나는

    if there is a value 같은 뭔가 다음을 제거하려면 if 조건에 따라 제거 할 NO file selected 필요

    <style type="text/css">  
        input[type='file'] { 
         color: transparent; 
        } 
    </style> 
    
    <input type="file" /> 
    

    을 선택한 파일이 없으면 파일을 추가하십시오.

    @if (Model.value != null) 
    { 
        Remove the no file chosen 
    } 
    else 
    { 
        Add the no File chosen 
    } 
    

    가능합니까? 나는 당신이 CSS 클래스와 이에 대한 JS의 비트를 사용할 수 있습니다

    +0

    가능한 중복 [난에 파일 입력에서 "어떤 파일을 선택하지"툴팁을 제거하는 방법 크롬?] (http://stackoverflow.com/questions/12035400/how-can-i-remove-the-no-file-chosen-tooltip-from-a-file-input-in-chrome) – undefined

    +0

    @ undefined- 아니오 그것은 내가 이미 그것을 읽었 기 때문에 조건에 기반하지 않습니다 ... –

    +0

    조건을 추가하는 것은 그리 어렵지 않습니다 (_if 그게 유일한 문제입니다). – undefined

    답변

    1

    MVC5 프로젝트를 ... 사용

    @if(Model.value != null){ 
        <input type="file" onchange="fileOnchange(this)" class="notext"/> 
        <script> 
         function fileOnchange(el){ 
         if(el.value){ 
          el.className = ""; 
         } 
         else{ 
          el.className = "notext"; 
         } 
         } 
        <script/> 
        <style type="text/CSS"> 
        .notext{ 
         color: transparent; 
        } 
        <style/> 
        } 
        else 
        { 
        <input type="file" /> 
        } 
    
    +1

    대단히 고맙습니다. :) !!!! –

    +0

    당신은 환영합니다! Goodluck을해라! –

    관련 문제