function trim(strText) { // this will get rid of leading spaces while (strText.substring(0,1) == ' ') strText = strText.substring(1, strText.length); // this will get rid of trailing spaces while (strText.substring(strText.length-1,strText.length) == ' ') strText = strText.substring(0, strText.length-1); return strText; } function ValidateNumber(textbox){ if(textbox.value != ""){ if(isNaN(textbox.value)){ alert("Please enter a number."); textbox.focus(); } } } function ConfirmDelete(sName, sAdditionalText){ var strConfirm = "Are you sure you want to delete '" + sName + "'?"; if(sAdditionalText != ""){ strConfirm += "\n" + sAdditionalText; } return confirm(strConfirm); } function IsValidEmail(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; }