// Removes leading whitespaces function LTrim( value ) { var re = /\s*((\S+\s*)*)/; return value.replace(re, "$1"); } // Removes ending whitespaces function RTrim( value ) { var re = /((\s*\S+)*)\s*/; return value.replace(re, "$1"); } // Removes leading and ending whitespaces function trim( value ) { return LTrim(RTrim(value)); } function clearTextBox(){ alert(document.getElementById('textfield').value); //document.getElementById('textfield').value=''; } function isValidEmail(strEmail){ validRegExp = /^[\w\.-]+@[a-z,A-Z,0-9-]+[\.]{1}[a-zA-Z]{2,}[[\.]?[a-zA-Z]{0,2}$/i; // search email text for regular exp matches if (strEmail.search(validRegExp) == -1) { return false; } return true; } function isValidUserName(val) { validRegExp = /^[a-zA-Z. ]+$/i; // search email text for regular exp matches val = trim(val); if (val.search(validRegExp) == -1) { return false; } return true; } function isValidName(val) { validRegExp = /^[a-zA-Z ]+$/i; // search email text for regular exp matches val = trim(val); if (val.search(validRegExp) == -1) { return false; } return true; } function isValidAddress(addr){ //validRegExp = /^[0-9a-zA-Z\s\,./-]+$/; validRegExp = /^[0-9a-zA-Z \s,.\!\@\#\$\%\^\&\*\(\)\?\_\'\"/-]+$/; if (addr.match(validRegExp) == null) { return false; } return true; } function isValidComment(commt){ validRegExp = /^[0-9a-zA-Z \s,.\!\@\#\$\%\^\&\*\(\)\?\_\'\"/-]+$/; if (commt.match(validRegExp) == null) { return false; } return true; } function isValidPhone(val) { validRegExp = /^[0-9 +.{}-]+$/; // search email text for regular exp matches val = trim(val); if (val.match(validRegExp) == null) { return false; } return true; } function validate(){ document.getElementById('fname_err').innerHTML=''; document.getElementById('lname_err').innerHTML=''; document.getElementById('address_err1').innerHTML=''; document.getElementById('city_err').innerHTML=''; document.getElementById('state_err').innerHTML=''; document.getElementById('zip_err').innerHTML=''; document.getElementById('phone_err').innerHTML=''; document.getElementById('email_err').innerHTML=''; var firstname = trim(document.getElementById('txtFirst').value); var secondname = trim(document.getElementById('txtSecond').value); var address = trim(document.getElementById('txtAddress1').value); var city = trim(document.getElementById('txtCity').value); var state = trim(document.getElementById('txtState').value); var zip = trim(document.getElementById('txtZip').value); var phone = trim(document.getElementById('txtPhone').value); var email = trim(document.getElementById('txtEmail').value); var flag=true; if (!isValidName(firstname) || firstname.length<1){ document.getElementById('fname_err').innerHTML='Invalid First Name'; document.getElementById('fname_err').style.color='red'; flag=false; } if (secondname.length>1 || secondname == ""){ if (!isValidName(secondname)){ document.getElementById('lname_err').innerHTML='Invalid Last Name'; document.getElementById('lname_err').style.color='red'; flag=false; } } if (!isValidAddress(address)){ document.getElementById('address_err1').innerHTML='Invalid Address'; document.getElementById('address_err1').style.color='red'; flag=false; } if (!isValidName(city) || city.length<3){ document.getElementById('city_err').innerHTML='Invalid City name'; document.getElementById('city_err').style.color='red'; flag=false; } if (!isValidName(state)){ document.getElementById('state_err').innerHTML='Invalid State Name'; document.getElementById('state_err').style.color='red'; flag=false; } if (zip.length==0 ){ document.getElementById('zip_err').innerHTML='Invalid Zip Code'; document.getElementById('zip_err').style.color='red'; flag = false; } if (zip.length!=0 ){ if(zip.length<4 || zip.length>7 || !isValidPhone(zip)) { document.getElementById('zip_err').innerHTML='Invalid Zip Code'; document.getElementById('zip_err').style.color='red'; flag = false; } } if (phone.length>1){ if(phone.length<6 || !isValidPhone(phone)) { document.getElementById('phone_err').innerHTML='Invalid Phone No.'; document.getElementById('phone_err').style.color='red'; flag = false; } } if (!isValidEmail(email) || email.length<5){ document.getElementById('email_err').innerHTML='Invalid Email'; document.getElementById('email_err').style.color='red'; flag=false; } if(flag==false) return false; else return true; } function validateUD(){ document.getElementById('fname_err').innerHTML=''; document.getElementById('lname_err').innerHTML=''; document.getElementById('address_err').innerHTML=''; document.getElementById('city_err').innerHTML=''; document.getElementById('phone_err').innerHTML=''; document.getElementById('email_err').innerHTML=''; var firstname = trim(document.getElementById('txtFirst').value); var secondname = trim(document.getElementById('txtSecond').value); var address = escape(trim(document.getElementById('txtAddress').value)); var city = trim(document.getElementById('txtCity').value); var phone = trim(document.getElementById('txtPhone').value); var email = trim(document.getElementById('txtEmail').value); var flag=true; if (!isValidName(firstname) || firstname.length<1){ document.getElementById('fname_err').innerHTML='Invalid First Name'; document.getElementById('fname_err').style.color='red'; flag=false; } if (secondname.length>1 || secondname == ""){ if (!isValidName(secondname)){ document.getElementById('lname_err').innerHTML='Invalid Last Name'; document.getElementById('lname_err').style.color='red'; flag=false; } } if (!isValidAddress(address) && address.length<1){ document.getElementById('address_err').innerHTML='Invalid Address'; document.getElementById('address_err').style.color='red'; flag=false; } if (!isValidAddress(city) || city.length<3){ document.getElementById('city_err').innerHTML='Invalid City name'; document.getElementById('city_err').style.color='red'; flag=false; } if (phone.length>1){ if(phone.length<6 || !isValidPhone(phone)) { document.getElementById('phone_err').innerHTML='Invalid Phone No.'; document.getElementById('phone_err').style.color='red'; flag = false; } } if (!isValidEmail(email) || email.length<5){ document.getElementById('email_err').innerHTML='Invalid Email'; document.getElementById('email_err').style.color='red'; flag=false; } if(flag==false) return false; else return true; } function validateUD2(){ document.getElementById('fname_err2').innerHTML=''; document.getElementById('lname_err2').innerHTML=''; document.getElementById('address_err2').innerHTML=''; document.getElementById('city_err2').innerHTML=''; document.getElementById('phone_err2').innerHTML=''; document.getElementById('email_err2').innerHTML=''; var firstname = trim(document.getElementById('txtFirst2').value); var secondname = trim(document.getElementById('txtSecond2').value); var address = escape(trim(document.getElementById('txtAddress2').value)); var city = trim(document.getElementById('txtCity2').value); var phone = trim(document.getElementById('txtPhone2').value); var email = trim(document.getElementById('txtEmail2').value); var flag=true; if (!isValidName(firstname) || firstname.length<1){ document.getElementById('fname_err2').innerHTML='Invalid First Name'; document.getElementById('fname_err2').style.color='red'; flag=false; } if (secondname.length>1 || secondname == ""){ if (!isValidName(secondname)){ document.getElementById('lname_err2').innerHTML='Invalid Last Name'; document.getElementById('lname_err2').style.color='red'; flag=false; } } if (!isValidAddress(address) && address.length<1){ document.getElementById('address_err2').innerHTML='Invalid Address'; document.getElementById('address_err2').style.color='red'; flag=false; } if (!isValidAddress(city) || city.length<3){ document.getElementById('city_err2').innerHTML='Invalid City name'; document.getElementById('city_err2').style.color='red'; flag=false; } if (phone.length>1){ if(phone.length<6 || !isValidPhone(phone)) { document.getElementById('phone_err2').innerHTML='Invalid Phone No.'; document.getElementById('phone_err2').style.color='red'; flag = false; } } if (!isValidEmail(email) || email.length<5){ document.getElementById('email_err2').innerHTML='Invalid Email'; document.getElementById('email_err2').style.color='red'; flag=false; } if(flag==false) return false; else return true; } function validateUD3(){ document.getElementById('fname_err3').innerHTML=''; document.getElementById('lname_err3').innerHTML=''; document.getElementById('address_err3').innerHTML=''; document.getElementById('city_err3').innerHTML=''; document.getElementById('phone_err3').innerHTML=''; document.getElementById('email_err3').innerHTML=''; var firstname = trim(document.getElementById('txtFirst3').value); var secondname = trim(document.getElementById('txtSecond3').value); var address = escape(trim(document.getElementById('txtAddress3').value)); var city = trim(document.getElementById('txtCity3').value); var phone = trim(document.getElementById('txtPhone3').value); var email = trim(document.getElementById('txtEmail3').value); var flag=true; if (!isValidName(firstname) || firstname.length<1){ document.getElementById('fname_err3').innerHTML='Invalid First Name'; document.getElementById('fname_err3').style.color='red'; flag=false; } if (secondname.length>1 || secondname == ""){ if (!isValidName(secondname)){ document.getElementById('lname_err3').innerHTML='Invalid Last Name'; document.getElementById('lname_err3').style.color='red'; flag=false; } } if (!isValidAddress(address) && address.length<1){ document.getElementById('address_err3').innerHTML='Invalid Address'; document.getElementById('address_err3').style.color='red'; flag=false; } if (!isValidAddress(city) || city.length<3){ document.getElementById('city_err3').innerHTML='Invalid City name'; document.getElementById('city_err3').style.color='red'; flag=false; } if (phone.length>1){ if(phone.length<6 || !isValidPhone(phone)) { document.getElementById('phone_err3').innerHTML='Invalid Phone No.'; document.getElementById('phone_err3').style.color='red'; flag = false; } } if (!isValidEmail(email) || email.length<5){ document.getElementById('email_err3').innerHTML='Invalid Email'; document.getElementById('email_err3').style.color='red'; flag=false; } if(flag==false) return false; else return true; } function idsearch(){ var val = trim(document.getElementById('textfield').value); if(val=='Search Location or Property ID') val = ""; /*if(val!='') closeparent(); */ if (val=='' || val=='Search Location or Property ID') { alert('Invalid search parameter'); return false; } else { url=window.location.href; arrsplitted=url.split('/'); if (arrsplitted[arrsplitted.length-2]=='agents') document.fd.action='../view.php?pst=1&textfield='+val; else document.fd.action='view.php?pst=1&textfield='+val; document.fd.submit() return true; } } function deleteSearch(id) { if(confirm("Are you sure you want to delete?")) { location.href="mysavedsearches.php?option=delete&id="+id; } }