Javascript - Text Field Submits To A Popup Window
I need to have this logic ( textfield ) (submit button) Person enters a string of numbers/letters - if its right; a popup window happens showing a pdf. if its wrong validation happ
Solution 1:
HTML:
<form onsubmit="return false;">
<inputtype="text"/>
<inputtype="submit"/>
</form>
Javascript:
$('form').submit(function() {
if ($('input[type=text]').val() == "some_pdf.pdf") {
window.open("http://link_to_some_pdf.com/some_pdf.pdf");
} elseif ($('input[type=text]').val() == "some_other_pdf.pdf") {
window.open("http://link_to_some_other_pdf.com/some_other_pdf.pdf");
} else {
alert("Not a valid PDF! Try again!");
}
});
jsfiddle: http://jsfiddle.net/vu26C/
Post a Comment for "Javascript - Text Field Submits To A Popup Window"