function valForm() { // alert('IN'); var o = document.getElementById('order'); // CHECK DEFAULT var req = new Array('first_name', 'last_name', 'address', 'city', 'zip', 'phone_number', 'email'); //'donation_from', valid = true; for(var f in req) { o[req[f]].style.backgroundColor = '#fff'; // alert(o[req[f]].value); if (!o[req[f]].value) { o[req[f]].style.backgroundColor = '#ff0'; valid = false; } } // check total greater than 0 if (o["totalamount"].value == 0) { o["totalamount"].style.backgroundColor = '#ff0'; alert('You have not entered a contribution'); valid = false; } if ( ( o["donation_from"][0].checked == false ) && ( o["donation_from"][1].checked == false ) ) { alert('Please select one of the Donation From options'); document.getElementById('thedontype').style.backgroundColor = '#ff0'; valid = false; } if (!valid) {alert('Please complete any highlighted fields to continue');} return valid; } function numbersonly(e, decimal) { var key; var keychar; if (window.event) { key = window.event.keyCode; } else if (e) { key = e.which; } else { return true; } keychar = String.fromCharCode(key); if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) { return true; } else if ((("0123456789").indexOf(keychar) > -1)) { return true; } else if (decimal && (keychar == ".")) { return true; } else return false; } function data_change(field) { var check = true; var value = field.value; //get characters //check that all characters are digits, ., -, or "" for(var i=0;i < field.value.length; ++i) { var new_key = value.charAt(i); //cycle through characters if(((new_key < "0") || (new_key > "9")) && !(new_key == "")) { check = false; break; } } //apply appropriate colour based on value if(!check) { field.style.backgroundColor = "red"; document.getElementById('badamount').style.visibility = 'visible'; } else { field.style.backgroundColor = "white"; document.getElementById('badamount').style.visibility = 'hidden'; // CALCULATE WHICH CHECKBOX IS SELECTED //var o = document.getElementById('order'); var theamount = Number(document.getElementById("contribution").value); document.getElementById("totalamount").value = theamount; if(theamount >= 1 && theamount < 250){ document.getElementById('cont_0').style.color = '#990000'; document.getElementById('cont_0').style.fontWeight = 'bold'; document.getElementById('cont_1').style.color = '#CCCCCC'; document.getElementById('cont_1').style.fontWeight = 'normal'; document.getElementById('cont_2').style.color = '#CCCCCC'; document.getElementById('cont_2').style.fontWeight = 'normal'; document.getElementById('cont_3').style.color = '#CCCCCC'; document.getElementById('cont_3').style.fontWeight = 'normal'; document.getElementById('cont_4').style.color = '#CCCCCC'; document.getElementById('cont_4').style.fontWeight = 'normal'; document.getElementById('cont_5').style.color = '#CCCCCC'; document.getElementById('cont_5').style.fontWeight = 'normal'; } else if(theamount >= 250 && theamount < 500){ document.getElementById('cont_0').style.color = '#CCCCCC'; document.getElementById('cont_0').style.fontWeight = 'normal'; document.getElementById('cont_1').style.color = '#990000'; document.getElementById('cont_1').style.fontWeight = 'bold'; document.getElementById('cont_2').style.color = '#CCCCCC'; document.getElementById('cont_2').style.fontWeight = 'normal'; document.getElementById('cont_3').style.color = '#CCCCCC'; document.getElementById('cont_3').style.fontWeight = 'normal'; document.getElementById('cont_4').style.color = '#CCCCCC'; document.getElementById('cont_4').style.fontWeight = 'normal'; document.getElementById('cont_5').style.color = '#CCCCCC'; document.getElementById('cont_5').style.fontWeight = 'normal'; } else if(theamount >= 500 && theamount < 1000){ document.getElementById('cont_0').style.color = '#CCCCCC'; document.getElementById('cont_0').style.fontWeight = 'normal'; document.getElementById('cont_1').style.color = '#CCCCCC'; document.getElementById('cont_1').style.fontWeight = 'normal'; document.getElementById('cont_2').style.color = '#990000'; document.getElementById('cont_2').style.fontWeight = 'bold'; document.getElementById('cont_3').style.color = '#CCCCCC'; document.getElementById('cont_3').style.fontWeight = 'normal'; document.getElementById('cont_4').style.color = '#CCCCCC'; document.getElementById('cont_4').style.fontWeight = 'normal'; document.getElementById('cont_5').style.color = '#CCCCCC'; document.getElementById('cont_5').style.fontWeight = 'normal'; } else if(theamount >= 1000 && theamount < 5000){ document.getElementById('cont_0').style.color = '#CCCCCC'; document.getElementById('cont_0').style.fontWeight = 'normal'; document.getElementById('cont_1').style.color = '#CCCCCC'; document.getElementById('cont_1').style.fontWeight = 'normal'; document.getElementById('cont_2').style.color = '#CCCCCC'; document.getElementById('cont_2').style.fontWeight = 'normal'; document.getElementById('cont_3').style.color = '#990000'; document.getElementById('cont_3').style.fontWeight = 'bold'; document.getElementById('cont_4').style.color = '#CCCCCC'; document.getElementById('cont_4').style.fontWeight = 'normal'; document.getElementById('cont_5').style.color = '#CCCCCC'; document.getElementById('cont_5').style.fontWeight = 'normal'; } else if(theamount >= 5000 && theamount < 15000){ document.getElementById('cont_0').style.color = '#CCCCCC'; document.getElementById('cont_0').style.fontWeight = 'normal'; document.getElementById('cont_1').style.color = '#CCCCCC'; document.getElementById('cont_1').style.fontWeight = 'normal'; document.getElementById('cont_2').style.color = '#CCCCCC'; document.getElementById('cont_2').style.fontWeight = 'normal'; document.getElementById('cont_3').style.color = '#CCCCCC'; document.getElementById('cont_3').style.fontWeight = 'normal'; document.getElementById('cont_4').style.color = '#990000'; document.getElementById('cont_4').style.fontWeight = 'bold'; document.getElementById('cont_5').style.color = '#CCCCCC'; document.getElementById('cont_5').style.fontWeight = 'normal'; } else if(theamount >= 15000 && theamount < 9999999999){ document.getElementById('cont_0').style.color = '#CCCCCC'; document.getElementById('cont_0').style.fontWeight = 'normal'; document.getElementById('cont_1').style.color = '#CCCCCC'; document.getElementById('cont_1').style.fontWeight = 'normal'; document.getElementById('cont_2').style.color = '#CCCCCC'; document.getElementById('cont_2').style.fontWeight = 'normal'; document.getElementById('cont_3').style.color = '#CCCCCC'; document.getElementById('cont_3').style.fontWeight = 'normal'; document.getElementById('cont_4').style.color = '#CCCCCC'; document.getElementById('cont_4').style.fontWeight = 'normal'; document.getElementById('cont_5').style.color = '#990000'; document.getElementById('cont_5').style.fontWeight = 'bold'; } else{ document.getElementById('cont_0').style.color = '#CCCCCC'; document.getElementById('cont_0').style.fontWeight = 'normal'; document.getElementById('cont_1').style.color = '#CCCCCC'; document.getElementById('cont_1').style.fontWeight = 'normal'; document.getElementById('cont_2').style.color = '#CCCCCC'; document.getElementById('cont_2').style.fontWeight = 'normal'; document.getElementById('cont_3').style.color = '#CCCCCC'; document.getElementById('cont_3').style.fontWeight = 'normal'; document.getElementById('cont_4').style.color = '#CCCCCC'; document.getElementById('cont_4').style.fontWeight = 'normal'; document.getElementById('cont_5').style.color = '#CCCCCC'; document.getElementById('cont_5').style.fontWeight = 'normal'; } } } function setCheckedValue(radioObj, newValue) { if(!radioObj) return; var radioLength = radioObj.length; if(radioLength == undefined) { radioObj.checked = (radioObj.value == newValue.toString()); return; } for(var i = 0; i < radioLength; i++) { radioObj[i].checked = false; if(radioObj[i].value == newValue.toString()) { radioObj[i].checked = true; } } }