I am trying to add field validation with Javascript on a SmartCapture form. The field validation is working, however I get POST 500 (Internal Server Error). For some reason, the post method breaks when I add the validation.

Here below is the code (only the parts relevant to this issue). Can you please help? Thanks!

<form id="smartcapture-block-avp824vcmv6" class="smartcapture-content-wrapper fuelux" onsubmit="return validateDate()">

<script type="text/javascript"> 

var today = new Date();
today.setHours(0, 0, 0, 0);

console.log ("Current date is: " + today);
   function validateDate() 
   var fday=document.getElementsByClassName("select day")[0].value;
     console.log("fday is: "+fday);
   var fmonth=document.getElementsByClassName("select month")[0].value; 
   var fyear=document.getElementsByClassName("select year")[0].value; 
     var inputDate = fday + "/" + fmonth + "/" + fyear;
     var inputDate = new Date(inputDate);


     if (inputDate <= today) 
     console.log("input date earlier than today");
   var Valert = "Date should not be earlier than today \n"; 
     console.log("input date later than today");
   var Valert = ""; 
     if (submitOK=="false") 
   return false; 



Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.