function ismaxlength(obj){ var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "" if (obj.getAttribute && obj.value.length>mlength) obj.value=obj.value.substring(0,mlength) } function actionForm(action) { if (action=='cancel') { document.location = "../index.php"; return; } if (action=='submit') { document.dataForm.action = "updateprices.php"; if (validatePage()) { //document.dataForm.actionid.value = 1; document.dataForm.submit(); } } if (action=='submitSearch') { document.dataForm.action = "checkreservation.php"; if (validateSearchPage()) { //document.dataForm.actionid.value = 1; document.dataForm.submit(); } } } function validatePage() { if (document.forms['dataForm'].elements['price_type_period'].checked) { if (document.forms['dataForm'].elements['theDate1'].value == '' && document.forms['dataForm'].elements['theDate2'].value == '') { alert('Proszę wybrać datę.'); document.forms['dataForm'].elements['theDate1'].focus(); return false; } } if (document.forms['dataForm'].elements['price'].value == '') { alert('Proszę wypełnić pole.'); document.forms['dataForm'].elements['price'].focus(); return false; } if (!isNumber(document.forms['dataForm'].elements['price'].value)) { alert('Pole powinno być kwotą.'); document.forms['dataForm'].elements['price'].focus(); return false; } if (document.forms['dataForm'].elements['price'].value > 9999.99) { alert('Wartość powinna być mniejsza od 9999.99.'); document.forms['dataForm'].elements['price'].focus(); return false; } return true; } function validateSearchPage() { if (document.forms['dataForm'].elements['theDate1'].value == '') { alert('Proszę wybrać datę.'); document.forms['dataForm'].elements['theDate1'].focus(); return false; } if (document.forms['dataForm'].elements['theDate2'].value == '') { alert('Proszę wybrać datę.'); document.forms['dataForm'].elements['theDate1'].focus(); return false; } if (document.forms['dataForm'].elements['theDate1'].value >= document.forms['dataForm'].elements['theDate2'].value) { alert('Błąd daty.'); document.forms['dataForm'].elements['theDate1'].focus(); return false; } var today='2012-02-06'; if (document.forms['dataForm'].elements['theDate1'].value < today ) { alert('Błąd daty.'); document.forms['dataForm'].elements['theDate1'].focus(); return false; } return true; }