Guys this code is returning false in a blank page after submit.What is the error of my code.
function send_serial(){
//Check date
var date=document.getElementById('date_field').value;
if(date==''||date==null){
alert('Please select the date.');
return false;
}
}
Your form tag should be
not
When you use
JAVASCRIPT:send_serialas the action, you’re asking the form to resubmit to a page whose content is supplied by the result of thesend_serialfunction.The
onsubmitevent handler is JavaScript, not a URL, so doesn’t need the JAVASCRIPT: in front. If the result of the event handler is false, it will cancel form submission. But you can’t just sayonsubmit="send_serial()"because then the result of the action handler would be nothing. The action handler is basically a function body that is plugged intofunction (event) { ... }so you need to have areturnin theonsubmitattribute.