Last active
December 10, 2015 21:58
-
-
Save nathanaelnsmith/4498300 to your computer and use it in GitHub Desktop.
Hide the file input using css, create a disabled text input to display file name once selected, use custom button to trigger file browse click.
After file is selected, JS grabs value and inserts into text field.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<span class="custom-upload"> | |
<i class="icomoon-upload"></i> | |
<input type="file" name="receipt" id="receipt" class="in-lrg"> | |
<input type="text" name="file-name" id="file-name" class="in-lrg" disabled> | |
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('form.form-add-service input[type=file]').live('change', function(){ | |
$(this).siblings('input').val($(this).val().replace('C:\\fakepath\\','')); | |
}); | |
$('form.form-add-service .custom-upload i').click(function(){ | |
$(this).siblings('input[type=file]').trigger('click'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.custom-upload { | |
position: relative; | |
background: #717174; | |
width: 526px; | |
height: 25px; | |
cursor: pointer; | |
display: block; | |
@include transition-property(all); | |
@include transition-duration(.5s); | |
&:hover { | |
background: #2199C4; | |
@include transition-duration(0); | |
input[name=file-name] { | |
border-color: #2199C4; | |
@include transition-duration(0); | |
} | |
} | |
input[name=receipt] { | |
display: none; | |
} | |
input[name=file-name] { | |
position: absolute; | |
top: 0px; | |
left: 33px; | |
width: 485px; | |
@include transition-property(all); | |
@include transition-duration(.5s); | |
} | |
i { | |
font-size: 26px; | |
color: #fff; | |
position: relative; | |
z-index: 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment