Showing posts with label Tricks. Show all posts
Showing posts with label Tricks. Show all posts

Custom styled file Upload

Monday, September 17, 2012


I know you are here with scratching your head about file upload.Here is lil trick you can do for any kind of style. ;)



Script
---------
put this in your script block.Don't forget  to include jquery script
 jQuery(document).ready(function() {
    $('input[type=file]').each(function(){
   
    var uploadbuttonlabeltext = $(this).attr('title'); //get title attribut for languagesettings
    if(uploadbuttonlabeltext == ''){
    var uploadbuttonlabeltext = 'Browse';
    }
   
    var uploadbutton = '<input type="button" class="new_form_submit1" value="Browse it!" />';
    $(this).wrap('<div class="fileinputs"></div>');
    $(this).addClass('file').css('opacity', 0); //set to invisible
    $(this).parent().append($('<div class="fakefile" />').append($('<input type="text" class="new_form_upload1"/>').attr('id',$(this).attr('id')+'__fake')).append(uploadbutton));
   
    $(this).bind('change', function() {
    $('#'+$(this).attr('id')+'__fake').val($(this).val());;
    });
    $(this).bind('mouseout', function() {
    $('#'+$(this).attr('id')+'__fake').val($(this).val());;
    });
    });
   
    });

css
-----------

input.file {
    height: 28px;
    opacity: 0;
    position: relative;
    text-align: right;
    z-index: 2;
}
div.fakefile {
    left: 0;
    position: absolute;
    top: 0;
    z-index: 1;
}

.new_form_upload1 {
    border: 1px solid #CCCCCC;
    color: #333333;
    font-size: 12px;
    height: 18px;
    margin-right: 10px;
    width: 140px;
}
.new_form_submit1 {
    background: none repeat scroll 0 0 #666666;
    border: medium none;
    color: #FFFFFF;
    font-size: 12px;
    height: 22px;
    text-align: left;
    width: 130px;
}

HTML
-------

<input id="FilesEventLogo" class="new_form_submit1 file" type="file" name="samplejpg">

happy coding

Continue Reading...

Jquery ui validator Custom Error

Monday, July 30, 2012










Include this script in you header after your "jquery.validate.js" >its simple trick to customize your whole array of error array.

jQuery.extend(jQuery.validator.messages, {
    required: "This field is required.",
    remote: "Use another Email.It is alreadt taken",
    email: "Please enter a valid email address.",
    url: "Please enter a valid URL.",
    date: "Please enter a valid date.",
    dateISO: "Please enter a valid date (ISO).",
    number: "Please enter a valid number.",
    digits: "Please enter only digits.",
    creditcard: "Please enter a valid credit card number.",
    equalTo: "Please enter the same value again.",
    accept: "Please enter a value with a valid extension.",
    maxlength: jQuery.validator.format("Please enter no more than {0} characters."),
    minlength: jQuery.validator.format("Please enter at least {0} characters."),
    rangelength: jQuery.validator.format("Please enter a value between {0} and {1} characters long."),
    range: jQuery.validator.format("Please enter a value between {0} and {1}."),
    max: jQuery.validator.format("Please enter a value less than or equal to {0}."),
    min: jQuery.validator.format("Please enter a value greater than or equal to {0}.")
});
Happy coding :)

Continue Reading...

Test site cross-browser

Wednesday, July 25, 2012



Coders And Ui Developers are tired of checking their site over different browsers.Its good to have  online platform where we can check errors and view in different browser.Below there are some good site where you can do those action.







Browsershots












Adobe BrowserLab


















Litmusapp












vmware













IE Tester














NetMechanic













Browsera









Enjoy Testing

Continue Reading...