Schleid Alex

Schleid Alex

  • NA
  • 361
  • 48.2k

Jquery to load page automatically

Dec 1 2020 5:58 PM
Hi there,
I have a view with an input field and a button when the button is clicked it triggers a jquery function to check where the value in the field is null or not if null I show a jquery alert saying the value cannot be nul
here is the script
 
$(document).ready(function(){
$('#btnAdd).on('click', function(){
if($('#Quantity).val()>0) 
{
....
}
else
{
alert('Quantity cannot be null')
}
})
 my problem is after the alert is displayed it goes straight to the index page instead of staying on the create one. I dunno why, could someone help me out please
 
Regard
 
Schleid

Answers (7)