This simple html form that creates one input field with type "file", one submit button
<!DOCTYPE html>
<html>
<head><title>Enable Submit button after file selected</title></head>
<body>
<form acton="#" method="post">
<input type="file" id="file"/></br>
<input type="submit" id="submit" value="Submit" disabled="true" />
</form>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="enable_submit_btn.js"></script>
</body>
</html>
Below is a jquery code for above html form. Initially the Submit button is disabled. After selecting the file(of any type), the Submit button is enabled.
//enable_submit_btn.js
$(document).ready(function(){
$('input').change(function(){
$('#submit').removeAttr('disabled');
});
});
<!DOCTYPE html>
<html>
<head><title>Enable Submit button after file selected</title></head>
<body>
<form acton="#" method="post">
<input type="file" id="file"/></br>
<input type="submit" id="submit" value="Submit" disabled="true" />
</form>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="enable_submit_btn.js"></script>
</body>
</html>
Below is a jquery code for above html form. Initially the Submit button is disabled. After selecting the file(of any type), the Submit button is enabled.
//enable_submit_btn.js
$(document).ready(function(){
$('input').change(function(){
$('#submit').removeAttr('disabled');
});
});
No comments:
Post a Comment