I want to detect if an image has been selected. If so, then display some text otherwise if its empty display some other text. As soon as the image is selected, automatically different message should be shown not after clicking a button. The following is my code.
Html
<input type="file" name="picture" id="image" />
<div id="message">Add image</div>
Javascript
$(document).ready(
if ($('#image').get(0).files.length !== 0) {
function() {
$('#message').text('You added an image');
}
}
);
function(){}that should be there for the document ready, and moved it down into your if statement.