Can anybody please tell me how to trigger unpress event on Submit button
I am doing a validation on button press if any of the fields are empty . i am preventing th e navigation to second page. But the Submit button remains pressed after validation and if From or To field is left empty. enter code here
<form action="NewFile.html">
From:<input id="from" type="text" name="From-busstop">
To:<input id= "to" type="text" name="To-busstop">
How do you want to travel?:<Select id="how" name="How">
<option>Minimum Number of Hops</option>
<option>Maximum Bus Route Availability</option>
<option>Via Terminal Bus Stations Only</option>
<option>Direct Routes Only</option>
<option>Shortest Distance</option>
</Select>
<p>
<a href="#two" id="submit" data-direction="reverse" data-role="button" data-transition="flip" onClick="loadpage()"
>Submit"</a>
</p>
</form>
<script type="text/javascript">
$('#submit').on('click',function(e) {
var from = document.getElementById('from').value;
var to = document.getElementById('to').value;
var how = document.getElementById('how').value;
if(from.length < 1)
{
alert("From bus-stop is empty");
document.getElementById("from").focus();
e.preventDefault();
}
else if(to.length < 1)
{
alert("To bus-stop is empty");
document.getElementById("to").focus();
e.preventDefault();
}
});
</script>