var SOLVED = false; function ResetFieldColor(field) { field.style.background='white'; field.style.color='black'; } function ValidateFormLive() { var name = document.getElementById("name"); var email = document.getElementById("email"); var comment = document.getElementById("comment"); var inf = document.getElementById("__ec_s"); var submit = document.getElementById("__submit"); if(name.value.length>0 && email.value.length>0 && comment.value.length>0) { if(SOLVED) { // Captcha solved already, enable Submit button submit.disabled = 0; } else { // Captcha hasn't been solved yet, enable captcha field // Captcha field is disabled by default, // in an effort to reduce resource usage // from the live Ajax captcha challenge. inf.disabled = 0; document.getElementById("captcha_div").style.display = "block"; scroll(0,300); } } else { // Nothing has been entered into the form, disable the Submit button submit.disabled = 1; } } function OnCaptchaSolved() { // Captcha has been solved, disable captcha field // This is an effort to reduce resource usage, // no need for continously pinging the server with captcha solutions after it has been solved once var inf = document.getElementById("__ec_s"); inf.disabled = 1; var progressArrows = document.getElementById("progress_arrows"); progressArrows.src = "http://www.royaalz.com/captcha_valid.png"; progressArrows.style.display = "block"; progressArrows.style.backgroundColor = "black"; inf.title = "Security code verified. Access granted."; progressArrows.title = "Security code verified. Access granted."; document.getElementById("captcha_image").onclick=null; document.getElementById("captcha_image").title = "Security code verified. Access granted."; document.getElementById("captcha").style.display = "none"; document.getElementById("solved_msg").style.display = "block"; SOLVED = true; ValidateFormLive(); } function OnCaptchaUpdate() { document.getElementById("progress_arrows").style.display = "none"; } function textCounter(field, maxlimit) { if(field.value.length > maxlimit) { field.value = field.value.substring( 0, maxlimit ); alert( 'Comment can only be '+maxlimit+' characters in length.' ); return false; } else { /*countfield.value = maxlimit - field.value.length;*/ } } function ValidateFormSubmit() { // Validate E-mail Address var emailValid = false; var email = document.getElementById("email"); if((email.value==null)||(email.value=="")) { alert("Please enter your e-mail address. Your e-mail address will not be shown publically."); email.style.background = "red"; email.style.color = "white"; email.focus(); return false; } if(email.value.length > 64) { alert("Sorry, your e-mail address is too long. E-mail addresses must be less than 64 characters long."); email.style.background = "red"; email.style.color = "white"; email.focus(); return false; } if(echeck(email.value)==false) { alert("The e-mail address you entered is not valid. Please fix and verify your e-mail address."); email.style.background = "red"; email.style.color = "white"; email.focus(); return false; } // Validate Name var name = document.getElementById("name"); if((name.value==null)||(name.value=="")) { alert("Please enter your name or nickname."); name.style.background = "red"; name.style.color = "white"; name.focus(); return false; } if(name.value.length > 32) { alert("Your name is too long. Names must be less than 32 characters long."); name.style.background = "red"; name.style.color = "white"; name.focus(); return false; } // Validate URL var url = document.getElementById("url"); if(url.value.length > 128) { alert("Your URL is too long. URLs must be less than 128 characters long."); url.style.background = "red"; url.style.color = "white"; url.focus(); return false; } // Validate Comment var comment = document.getElementById("comment"); if(comment.value.length < 6) { alert("Your comment is too short. Comments must be at least 6 characters long."); comment.style.background = "red"; comment.style.color = "white"; comment.focus(); return false; } if(comment.value.length > 255) { alert("Your comment is too long. Comments must be less than 255 characters long."); comment.style.background = "red"; comment.style.color = "white"; comment.focus(); return false; } // Valid var inf = document.getElementById("__ec_s"); inf.disabled = 0; // Quickly enable Captcha field so that it gets submitted with the form (it is currently disabled) return true; } function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false } if (str.indexOf(at,(lat+1))!=-1){ return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false } if (str.indexOf(dot,(lat+2))==-1){ return false } if (str.indexOf(" ")!=-1){ return false } return true }