// JavaScript Document $(document).ready(function(){ $("input#Validate").click(function(event){ var purpose = $("[name=application$app_purpose]").val(); var exempt = $("input[name=application$fee_exempt_reason]:checked").val(); var respondent = $("input[name=ownership_report$owner_type]:checked").val(); var exempt_other = $("input[name=application$fee_exempt_other]").val(); var $error = 0; /* //Q4 Fee exempt reason if (exempt == undefined) { alert("Fee exempt Reason must be answered"); $("input[id^='AFER1']").focus(); $error = $error + 1; if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } } */ if (exempt == "O") { if (!exempt_other) { alert("Section I, Question 4, Fee Exempt reason of 'Other' requires additional information."); if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } $("input[id^='AFEO']").focus(); if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } $error = $error + 1; } } //Q5 Accurate date var acc_date = $("input[name=ownership_report$accurate_date]").val(); var curdate = $("[name=currentdate]").val(); function isDate(sDate) { var scratch = new Date(sDate); if (scratch.toString() == "NaN" || scratch.toString() == "Invalid Date") { return false; } else { return true; } }// end is Date if (!isDate(acc_date) && $error == 0) { alert("Accurate Date must be a valid date"); $("input[id^='ORAD']").focus(); $error = $error + 1; $("input[id^='ORAD']").focus(); event.preventDefault(); if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } } else { //check for Biennial , Validation and Resubmission or Amendment if (purpose == "OB" || purpose == "AMD" || purpose == "OR") { var cur=document.MainSection.currentdate.value; var acc=document.MainSection.ownership_report$accurate_date.value; var year=document.MainSection.currentyear.value; //not working in IE if ( acc > cur) { $error = $error + 1; alert("The 'Accurate as of' date must not be in the future."); if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } } else if (year = 2009 && $error == 0) { if (acc == "11/1/2009" || acc == "11/01/2009") { //do nothing } else { $error = $error + 1; alert("Section I, Question 5, The 'Accurate as of' date must be '11/1/2009' for a 2009 Biennial filing."); $("input[id^='ORAD']").focus(); if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } } } // end 2009 } else { var earlier=document.MainSection.earlierdate.value; var acc=document.getElementById("ORAD").value; //not working in IE if ( acc < earlier ) { $error = $error + 1; alert("Section I, Question 5, The 'Accurate as of' date must not be more than 60 days earlier than the current date for a non-biennial Ownership Report."); $("input[id^='ORAD']").focus(); if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } } } //end purpose } // FRN rules var $name=document.getElementById("ORNAME").value; var $frn=document.getElementById("ORFRN").value; if ($name.trim().length == 0 && $error == 0) { $error = $error + 1; alert("Section I, Question 7, Licensee Name must be answered."); $("input[id^='ORNAME']").focus(); event.preventDefault(); } // } else if ($frn.trim().length == 0 && $error == 0) { // $error = $error + 1; //alert("Section I, Question 7, Licensee FRN must be answered."); // $("input[id^='ORFRN']").focus(); // event.preventDefault(); //} else if ($frn.trim().length == 10 && $error == 0){ //do nothing //} else if ($error == 0) { // $error = $error + 1; // alert("Section I, Question 7, The specified Licensee's FRN does not appear to be a valid FRN."); // $("input[id^='ORFRN']").focus(); // event.preventDefault(); // event.returnValue = false; // Q8 Respondent if (respondent == undefined && $error == 0) { alert("Section I, Question 8, Respondent must be answered"); $("input[id^='OROT1']").focus(); $error = $error + 1; $("input[id^='OROTI']").focus(); if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } } //Certification var sig=document.MainSection.personal_info$sig_nameS.value; var name=document.MainSection.personal_info$nameS.value; var title=document.MainSection.personal_info$titleS.value; var num=document.MainSection.personal_info$phoneS.value; var sdate=document.MainSection.personal_info$date_enteredS.value; var cur=document.MainSection.currentdate.value; if (title.trim().length == 0 && $error == 0) { $error = $error + 1; alert("Section III Certification, Official Title must be answered."); $("input[id^='PISTITLE']").focus(); event.preventDefault(); } else if (name.trim().length == 0 && $error == 0) { $error = $error + 1; alert("Section III Certification, Title/Name of Respondent must be answered."); $("input[id^='PISNAME']").focus(); event.preventDefault(); } else if (sig.trim().length == 0 && $error == 0) { $error = $error + 1; alert("Section III Certification, Signature (typed name) must be answered."); $("input[id^='PISSIG']").focus(); event.preventDefault(); } if (!isDate(sdate) && $error == 0) { $error = $error + 1; alert("Section III Certification, Date must be a valid date."); $("input[id^='PISDATE']").focus(); event.preventDefault(); } // NOt working in IE if ( sdate > cur && $error == 0 && (sdate.length == cur.length) ) { $error = $error + 1; alert("Section III Certification, Date must not be in the future."); $("input[id^='PISDATE']").focus(); event.preventDefault(); } /*//Phone number if (num.length > 0 && $error == 0) { var numpar = parseInt(num); if (isNaN(numpar)) { $error = $error + 1; alert("Section III Certification, Telephone Number must contain digits only."); $("input[id^='PISPHONE']").focus(); event.preventDefault(); } else if (num.trim().length == 10 && $error == 0) { //do nothing } else if ($error == 0) { $error = $error + 1; alert('Section III Certification, Telephone Number must be 10 digits and contain no spaces.'); $("input[id^='PISPHONE']").focus(); event.preventDefault(); event.returnValue = false; } } */ }); //end validate }); //end ready