« Previous entry | Next entry » Browse > Snippets
Skip to comments (3)
javascript
Posted by pcnorb on Jan 23 2009 @ 15:57 :: 768 unique visits
function disableSubmitButton(status) {var x=document.getElementById("btn");
if (status == "no") {
x.disabled=false;
}
else if (status == "yes") {
x.disabled=true;
}
}
function showProgressBar(status) {
var bdy=document.getElementById("body");
if (status == "yes") {
ProgressImg = document.getElementById('inprogress_img');
document.getElementById("inprogress").style.visibility = "visible";
setTimeout("ProgressImg.src = ProgressImg.src",100);
bdy.style.background='gray';
}
else if (status == "no") {
ProgressImg = document.getElementById('inprogress_img');
document.getElementById("inprogress").style.visibility = "hidden";
setTimeout("ProgressImg.src = ProgressImg.src",100);
bdy.style.background='white';
}
}
function WAValidateRQ(formElement,errorMsg,focusIt,stopIt,trimWhite,inputType) {
var isValid = true;
if (!document.WAFV_Stop && !formElement.WAFV_Stop) {
if (inputType == "select") {
if (formElement.selectedIndex == -1) {
isValid = false;
}
else if (!formElement.options[formElement.selectedIndex].value || formElement.options[formElement.selectedIndex].value == "") {
isValid = false;
}
}
else if (inputType == "checkbox") {
if (!formElement.checked)
isValid = false;
}
else if (inputType == "radio") {
isValid = false;
if (formElement.checked)
isValid = true;
}
else if (inputType == "radiogroup") {
isValid = false;
for (var x=0; x<formElement.length; x++) {
if (formElement[x].checked && formElement[x].value!="") {
isValid = true;
break;
}
}
formElement = formElement[0];
}
else {
var value = formElement.value;
if (trimWhite) {
value = WAtrimIt(value);
}
if (value == "") {
isValid = false;
}
}
}
if (!isValid) {
WAAddError(formElement,errorMsg,focusIt,stopIt);
}
}
function WAValidateEM(formElement,value,errorMsg,focusIt,stopIt,required) {
var isValid = true;
if ((!document.WAFV_Stop && !formElement.WAFV_Stop) && !(!required && value=="")) {
var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat = /^(.+)@(.+)$/;
var accepted = "[^\\s\\(\\)><@,;:\\\\\\\"\\.\[\]]+";
var quotedUser = "(\"[^\"]*\")";
var ipDomainPat = /^[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})]$/;
var section = "(" + accepted + "|" + quotedUser + ")";
var userPat = new RegExp("^" + section + "(\\." + section + ")*$");
var domainPat = new RegExp("^" + accepted + "(\\." + accepted +")*$");
var theMatch = value.match(emailPat);
var acceptedPat = new RegExp("^" + accepted + "$");
var userName = "";
var domainName = "";
if (theMatch==null) {
isValid = false;
}
else {
userName = theMatch[1];
domainName = theMatch[2];
var domArr = domainName.split(".");
var IPArray = domainName.match(ipDomainPat);
for (x=0; x < userName.length; x++) {
if (userName.charCodeAt(x) > 127) {
isValid = false;
}
}
for (x=0; x < domainName.length; x++) {
if (domainName.charCodeAt(x) > 127) {
isValid = false;
}
}
if (userName.match(userPat) == null) {
isValid = false;
}
if (IPArray != null) {
for (var x=1; x<=4; x++) {
if (IPArray[x] > 255) {
isValid = false;
}
}
}
for (x=0; x < domArr.length; x++) {
if (domArr[x].search(acceptedPat) == -1 || domArr[x].length < 2) {
isValid = false;
}
}
if (domArr[domArr.length-1].length !=2 && domArr[domArr.length-1].search(knownDomsPat) == -1) {
isValid = false;
}
if (domArr.length < 2) {
isValid = false;
}
}
}
if (!isValid) {
WAAddError(formElement,errorMsg,focusIt,stopIt);
}
}
function WAAlertErrors(errorHead,errorFoot,setFocus,submitForm) {
if (!document.WAFV_StopAlert) {
document.WAFV_StopAlert = true;
if (document.WAFV_InvalidArray) {
document.WAFV_Stop = true;
var errorMsg = document.WAFV_Error;
if (errorHead!="")
errorMsg = errorHead + "\n" + errorMsg;
if (errorFoot!="")
errorMsg += "\n" + errorFoot;
document.MM_returnValue = false;
if (document.WAFV_Error!="")
alert(errorMsg.replace(/"/g,'"'));
else if (submitForm)
submitForm.submit();
if (setFocus && document.WAFV_Focus) {
document.tempFocus = document.WAFV_Focus;
setTimeout("document.tempFocus.focus();setTimeout('document.WAFV_Stop = false;document.WAFV_StopAlert = false;',1)",1);
}
else {
document.WAFV_Stop = false;
document.WAFV_StopAlert = false;
}
for (var x=0; x<document.WAFV_InvalidArray.length; x++) {
document.WAFV_InvalidArray[x].WAFV_Stop = false;
}
/*added to show progress bar
and disable submit button*/
showProgressBar('no');
disableSubmitButton('no');
}
else {
document.WAFV_Stop = false;
document.WAFV_StopAlert = false;
if (submitForm) {
submitForm.submit();
}
document.MM_returnValue = true;
}
document.WAFV_Focus = false;
document.WAFV_Error = false;
document.WAFV_InvalidArray = false;
}
}
function WAAddError(formElement,errorMsg,focusIt,stopIt) {
if (document.WAFV_Error) {
document.WAFV_Error += "\n" + errorMsg;
}
else {
document.WAFV_Error = errorMsg;
}
if (!document.WAFV_InvalidArray) {
document.WAFV_InvalidArray = new Array();
}
document.WAFV_InvalidArray[document.WAFV_InvalidArray.length] = formElement;
if (focusIt && !document.WAFV_Focus) {
document.WAFV_Focus = focusIt;
}
if (stopIt == 1) {
document.WAFV_Stop = true;
}
else if (stopIt == 2) {
formElement.WAFV_Continue = true;
}
else if (stopIt == 3) {
formElement.WAFV_Stop = true;
formElement.WAFV_Continue = false;
}
}
3 comments posted so far
Add your own »
2. On Jul 14 2009 @ 09:34 guest wrote:
AVI to DVD Converter,AVI to DVD Creator,iPhone Ringtone Maker for Mac,AVI Converter OS X,VOB Converter OS X,AVCHD Video Converter,FLV Converter,PowerPoint Converter,AVCHD Converter,Blue-Ray ripper,FLV to MOV Mac,VOB to DVD,HD Video Converter,iPod Playlist Transfer3. On Jan 05 2010 @ 14:56 uggbaileybutton wrote:
bailey button uggs-ugg boots cheap
ugg boots uk
ugg classic
1. On Apr 14 2009 @ 13:37 guest wrote:
Find information about tiffany ,gucci ,chanel and other jewelry online shopping at online shopping ,jewelry,craft,antique,daily news online collection at Online Collector ,Tiffany Jewelry including Tiffany Necklaces,Tiffany Rings, and tiffany bracelets…
Guide To Buy Tiffany Product , fashion jewelry provide,Tiffany,Oxette,Swarovski,CHANEL Jewelry Information
Find the discount gucci shoes
Louis Vuitton is luxury gifts, French fashion, the replica Louis Vuitton Handbag is woman best friend.Monogram Groom.
Offers Discount Louis Vuitton handbags and Louis Vuitton bags and all other designer handbags,free global fast shipping,low price and top quality.Monogram Jokes,Monogram Suede cheap Louis Vuitton
Louis Vuitton.
Looking For Gucci Shoes ? Gucci Store provide gucci Mens shoes,gucci Womens shoes
Wonderful Gucci shoes sale Gucci men's shoes and Gucci women's shoes at discount Gucci Shoes prices.
cheap gucci Shoes
Gucci Shoes and gucci clothing Spring - Summer 2009, Prada Shoes and prada clothing from the Latest Collection 2009 and Dolce Gabbana Clothing 2009
Gucci Loafers
Gucci Sneakers
Louis Vuitton Handbags
UGGs
Louis Vuitton Handbags
Gucci Shoes
Louis Vuitton
UGG Boots
Louis Vuitton Handbags
gucci shoes
Monogram Groom
Discount Louis Vuitton
UGG Boots