function validateLogin(theForm) { var retStatus = 0; // User Login Name Validation retStatus = allowedCharater(theForm.LogID.value,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456_7890-",24,true); if(retStatus==1) { alert("Please enter a value for the Login ID and try again."); } if(retStatus==2) { alert("Maximum of 15 characters are allowed in the Login ID."); } if(retStatus==3) { alert("Only letter , digit and \"_-\" are allowed in the Login ID."); } if(retStatus==0) { retStatus = startsOk(theForm.LogID.value,"-_"); if(retStatus!=0) { alert("Login ID can not start or end with \"-_\"."); } } if(retStatus!=0) { theForm.LogID.focus(); theForm.LogID.select(); return (false); } // Ends // User Password Checking retStatus = allowedCharater(theForm.PassWD.value, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU_-VWXYZ12345677890",15,true); if(retStatus==1) { alert("Please enter a value for the Password and try again."); } if(retStatus==2) { alert("Please enter at most 8 characters in the Password"); } if(retStatus==3) { alert("Please enter only letter, digit and \"_-\" characters in the Password."); } if(retStatus!=0) { theForm.PassWD.focus(); theForm.PassWD.select(); return (false); } // Ends return (true) } function allowedCharater(fieldToBeChecked, allowedChar,maxLength,isMust) { if(isMust && fieldToBeChecked=="") { return 1; } if(fieldToBeChecked.length>maxLength) { return 2; } var checkOK = allowedChar; var checkStr = fieldToBeChecked; for (i = 0; i < checkStr.length; i++) { ch = checkStr.charAt(i); for (j = 0; j < checkOK.length; j++) if (ch == checkOK.charAt(j)) break; if (j == checkOK.length) { return 3; } } return 0; } function startsOk(fieldToBeChecked,notAllowedChar) { var checkField = fieldToBeChecked; var notAllowed = notAllowedChar; var chStart = checkField.charAt(0); var chEnd = checkField.charAt(checkField.length-1); for (j = 0; j < notAllowed.length; j++) { var chNotAllowed = notAllowed.charAt(j); if((chStart == chNotAllowed) || (chEnd == chNotAllowed)) { return 1; // Not OK } } return 0; // OK }