leonidassavvides
04-23-2008, 08:19 AM
To below page there is a form with onsubmit return validation function well although validation works I can not find the js function in the code ?
http://dimitriavilla.com/book_here.htm
I want to add the validation function below to form so bookInDate<bookOutDate , how to include the two functions (& return keyword) to one onsubmit event handler ?
<script type="text/javascript">
function submitForm() {
if (document.book.Email.value == "") {
window.alert("You must enter your email address to submit form!");
return false;
}
var startDate = new Date(document.book.DATEFROM_YEAR.value,document.book.DATEFROM_MONTH.value-1,document.book.DATEFROM_DAY.value); // var startDate = new Date(document.forms[0].year.value,document.forms[0].month.value,document.forms[0].day.value);
var endDate = new Date(document.book.DATETO_YEAR.value,document.book.DATETO_MONTH.value-1,document.book.DATETO_DAY.value); // var endDate = new Date(document.forms[0].toyear.value,document.forms[0].tomonth.value,document.forms[0].today.value);
if (startDate.getTime() > endDate.getTime()) { // startDate.valueof() > endDate.valueof()
window.alert("You must enter Start Date prior End Date to submit form!");
return false;
}
else
return true;
} // end function p261 gosselin book
</script>
http://dimitriavilla.com/book_here.htm
I want to add the validation function below to form so bookInDate<bookOutDate , how to include the two functions (& return keyword) to one onsubmit event handler ?
<script type="text/javascript">
function submitForm() {
if (document.book.Email.value == "") {
window.alert("You must enter your email address to submit form!");
return false;
}
var startDate = new Date(document.book.DATEFROM_YEAR.value,document.book.DATEFROM_MONTH.value-1,document.book.DATEFROM_DAY.value); // var startDate = new Date(document.forms[0].year.value,document.forms[0].month.value,document.forms[0].day.value);
var endDate = new Date(document.book.DATETO_YEAR.value,document.book.DATETO_MONTH.value-1,document.book.DATETO_DAY.value); // var endDate = new Date(document.forms[0].toyear.value,document.forms[0].tomonth.value,document.forms[0].today.value);
if (startDate.getTime() > endDate.getTime()) { // startDate.valueof() > endDate.valueof()
window.alert("You must enter Start Date prior End Date to submit form!");
return false;
}
else
return true;
} // end function p261 gosselin book
</script>