How to display file name for custom styled input file using jquery?

You have to bind and trigger the change event on the [type=file] element and read the files name as: $(‘#file-upload’).change(function() { var i = $(this).prev(‘label’).clone(); var file = $(‘#file-upload’)[0].files[0].name; $(this).prev(‘label’).text(file); }); .custom-file-upload { border: 1px solid #ccc; display: inline-block; padding: 6px 12px; cursor: pointer; } <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script> <form> <label for=”file-upload” class=”custom-file-upload”> <i class=”fa fa-cloud-upload”></i> Upload … Read more

How to get a number value from an input field?

You had some mistakes in your HTML, but here is a working JSFiddle: Fiddle You you are trying to get elements by their ID, but you don’t give them an ID you give them a Name. Also, stop using inline JavaScript calls; it is bad practice. function Calculate() { var TotalProductionTime = document.getElementById(“TotalProductionTime”).value; var TotalProductionTimeInMinutes … Read more

What is the correct readonly attribute syntax for input text elements?

HTML5 spec: http://www.w3.org/TR/html5/forms.html#attr-input-readonly : The readonly attribute is a boolean attribute http://www.w3.org/TR/html5/infrastructure.html#boolean-attributes : The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value. If the attribute is present, its value must either be the empty string or a value that is an … Read more