I am making a webpage that has a csv form. I want to download csv file when I click the button and the window prompt is correct.
EX: I click the download button, a window prompt will popup I need to input "Hello" so that the authentication is correct, how do I download the csv form when input is correct and don't download when it is wrong. Thank you
here is my source:
Code
<a href="#" class="download" onclick="myFunction()">Download</a>
<script type="text/javascript">
$('.download').click(function(e) {
var person = prompt("Please enter download access", "Hello Admin");
e.preventDefault(); //stop the browser from following
if (person != "Hello") {
$('#auth__text').show();
$('#auth__text__success').hide();
document.getElementById("auth__text").innerHTML = "Wrong Access, You can't Download the CSV Data(s)";
} else {
$('#auth__text').hide();
$('#auth__text__success').show();
document.getElementById("auth__text__success").innerHTML = "You can now download the CSV Data(s)";
}
});
</script>