function isEmpty(str) { if (str == null || str == "" || str == " ") { return true; } else { return false; } } /* used for removing the blank Spaces */ function trim(str) { var temp = ""; for(var i = 0; i < str.length; i++) { if (str.charAt(i) != " ") break; } for(var j = str.length-1; j > 0; j--) { if (str.charAt(j) != " ") break; } for(var k = i; k <= j; k++) { temp = temp + str.charAt(k); } return temp; } function isMobileNum(entry) { var i = 1,len = 0; entry = trim(entry); len = entry.length; if( (entry.charAt(0) == '+') || (entry.charAt(0) >= '0' && entry.charAt(0) <= '9') ) { for(i = 1 ; i < len ; i++) { if(entry.charAt(i) < '0' || entry.charAt(i) > '9') return false; } } else { return false; } return true; } function isValidNumber(number) { var i; var len = number.length; for(i=0;i '9') return false; } return true; } function isValidPassword(str) { var re = /^[A-Za-z0-9]\w{2,}[A-Za-z0-9]$/; if (!re.test(str)) { return false; } return true; } function isValidEmail(email) { // a very simple email validation checking. // you can add more complex email checking if it helps if(email.length <= 0) { return true; } var splitted = email.match("^(.+)@(.+)$"); if(splitted == null) return false; if(splitted[1] != null ) { var regexp_user=/^\"?[\w-_\.]*\"?$/; if(splitted[1].match(regexp_user) == null) return false; } if(splitted[2] != null) { var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/; if(splitted[2].match(regexp_domain) == null) { var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/; if(splitted[2].match(regexp_ip) == null) return false; }// if return true; } return false; } function isValidURL(str) { var j = new RegExp(); j.compile("^[A-Za-z]+://[A-Za-z0-9-]+\.[A-Za-z0-9]+"); if (!j.test(str)) { return false; } return true; } function isValidNumCommaCombination(mobileValue) { var len = mobileValue.length; if(mobileValue.charAt(0) == ',') return false; if((mobileValue.charAt(0) >= '0' && mobileValue.charAt(0) <= '9') || mobileValue.charAt(0) == '+' ) { for(i=1;i '9') && mobileValue.charAt(i) != ',') return false; } } else { return false; } return true; } function isValidAddressRange(mobileValue) { var len = mobileValue.length; if(mobileValue.charAt(0) == ',' || mobileValue.charAt(0) == ';') return false; if((mobileValue.charAt(0) >= '0' && mobileValue.charAt(0) <= '9') || mobileValue.charAt(0) == '+' ) { for(i=1;i='0' && mobileValue.charAt(i) <= '9') || mobileValue.charAt(i) == ',' || mobileValue.charAt(i) == ';' || mobileValue.charAt(i) == '-') { continue; } else { return false; } } } else { return false; } return true; } function isValidAlphabet(str) { var len = str.length; for(i=0;i='A') || ( ch <='z' && ch >= 'a')) continue; else return false; } return true; } function isValidAlphaNum(str) { var len = str.length; for(i=0;i='A') || ( ch <='z' && ch >= 'a') || (ch <='9' && ch >='0')) continue; else return false; } return true; } function isValidSignature(str) { var len = str.length; for(i=0;i='A') || ( ch <='z' && ch >= 'a') || ch == ' ' || ch == '\n' || ch=='\r') continue; else return false; } return true; } function isValidName(str) { for (var i = 1; i < str.length; i++) { var ch = str.charAt(i); var firstChar = str.charAt(0); if ( firstChar <= '9' && firstChar >= '0') return false; if (((ch <= 'Z') && (ch >= 'A')) || ((ch <= 'z') && (ch >= 'a')) || ((ch <= '9') && (ch >= '0')) || ch == ' ') continue; else return false; } return true; } function isValidSectionName(str) { for (var i = 1; i < str.length; i++) { var ch = str.charAt(i); var firstChar = str.charAt(0); if ( firstChar <= '9' && firstChar >= '0') return false; if (!isValidAlphabet(firstChar)) return false; if (((ch <= 'Z') && (ch >= 'A')) || ((ch <= 'z') && (ch >= 'a')) || ((ch <= '9') && (ch >= '0')) || ch == ' ' || ch == '_') continue; else return false; } return true; } function isValidContentType(str) { var sArray = new Array(); sArray = str.split("/"); if(sArray.length != 2) { return false; } if(sArray[0].length == 0 || sArray[1].length == 0 ) { return false; } for (var i = 0; i < str.length; i++) { var ch = str.charAt(i); var firstChar = str.charAt(0); if ( firstChar <= '9' && firstChar >= '0') return false; if (!isValidAlphabet(firstChar)) return false; if (((ch <= 'Z') && (ch >= 'A')) || ((ch <= 'z') && (ch >= 'a')) || ((ch <= '9') && (ch >= '0')) || ch == '_' || ch == '/' || ch=='-' || ch == '.') continue; else return false; } return true; } function validateLoginForm(form,type) { if ( cookie_set == false) { alert("Cookies are not enabled"); return false; } if(type == 1) { if(isEmpty(trim(document.forms[0].username.value))) { alert('Please Enter Mobile Number'); document.forms[0].username.focus(); return false; } var username = trim(document.forms[0].username.value); if(!isMobileNum(username)) { alert('Please Enter Proper Mobile Number'); document.forms[0].username.focus(); return false; } if(isEmpty(trim(document.forms[0].password.value))) { alert('Please Enter Password'); document.forms[0].password.focus(); return false; } /* var password = trim(document.forms[0].password.value); if(!isValidPassword(password)) { alert('Please Enter Proper Password'); document.forms[0].password.focus(); return false; } */ document.forms[0].logintype.value = type; } if(type == 2) { if(isEmpty(trim(document.forms[1].unregiusername.value))) { alert('Please Enter Mobile Number'); document.forms[1].unregiusername.focus(); return false; } var username = trim(document.forms[1].unregiusername.value); if(!isMobileNum(username)) { alert('Please Enter Proper Mobile Number'); document.forms[1].unregiusername.focus(); return false; } if(isEmpty(document.forms[1].msgId.value)) { alert('Please Enter Message Key'); document.forms[1].msgId.focus(); return false; } document.forms[1].logintype.value = type; /* var password = trim(document.forms[1].msgId.value); if(!isValidPassword(password)) { alert('Please Enter Proper Message Key'); document.forms[1].msgId.focus(); return false; } */ } return true; } function openUrl(url,type) { window.open(url,type,'left=250,top=200,directories=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,status=no,width=550,height=325'); //window.open(url,type,'left=window.width()/2,top=window.height()/2,directories=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,status=no,width=760,height=330'); } function openAddress(url) { window.open(url,'p_radio','left=200,top=200,directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,copyhistory=no,status=no,width=513,height=285'); } function openUpload(url,type) { window.open(url,type,'left=200,top=300,directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,copyhistory=no,status=no,width=600,height=240'); } function openForgotPasswordUrl(url,type) { window.open(url,type,'left=250,top=200,directories=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,status=no,width=525,height=275'); } function openHelpPopup(url) { var WindowObjectReference; WindowObjectReference = window.open(url,"WebtopHelp", "left=200,top=85,scrollbars=yes,resizable=no,width=470,height=500"); } function openFAQPopup(url) { var WindowObjectReference1; WindowObjectReference1 = window.open(url,"WebtopFAQ", "left=200,top=85,scrollbars=yes,resizable=no,width=470,height=500"); } function validateAddContactForm(form) { if(isEmpty(trim(form.name.value))) { alert('Please Enter Name'); form.name.focus(); return false; } var name = form.name; if(!isValidName(trim(name.value))) { alert('Please Enter Proper Name'); name.focus(); return false; } var isSelected = 0; for(i=0;i