Javascript return false not working -
guys code returning false in blank page after submit.what error of code.
function send_serial(){ //check date var date=document.getelementbyid('date_field').value; if(date==''||date==null){ alert('please select date.'); return false; } }
your form tag should be
<form onsubmit="return send_serial();">
not
<form action="javascript:send_serial();">
when use javascript:send_serial
action, you're asking form resubmit page content supplied result of send_serial
function.
the onsubmit
event handler javascript, not url, doesn't need javascript: in front. if result of event handler false, cancel form submission. can't onsubmit="send_serial()"
because result of action handler nothing. action handler function body plugged function (event) { ... }
need have return
in onsubmit
attribute.
Comments
Post a Comment