sub document_onkeydown 'Van enter een Tab maken set we = window.event if we.keyCode = 13 then 'make enter work as tab if we.srcElement.type<>"button" then if we.srcElement.type<>"reset" then if we.srcElement.type<>"file" then if we.srcElement.type<>"image" then we.keycode=9 end if end if end if end if end if if we.keycode =38 then window.event.shiftKey=true '-> this doesn't work... window.event.keycode=9 window.event.returnvalue = true end if if we.keycode =40 then window.event.keycode=9 window.event.returnvalue = true end if end sub function validateField(myValue,myValidate,myPattern) ' "myValidate" indicates if we need to use a regular expression, or if we are going to use ' some other form af validation. ' The following are the possible values that can be passed in the "myValidate" variable. ' (you can always add your own as well) ' regexp - If we use a regular expression, we also have an associated pattern defined ' by the 'PATTERN' attribute. The following are the possible "pre-determined" ' values that can be passed in the "myPattern" variable. ' phone_1 - phone number must match the pattern xxx-xxx-xxxx ' phone_2 - phone number must match the pattern (xxx)xxx-xxxx ' zip_1 - zip must match the pattern xxxxx ' zip_2 - zip must match the pattern xxxxx-xxxx ' You can also pass your own regular expression throught the "myPattern" variable ' email - Makes sure the email has no illegal characters and is in a valid format ' date - Makes sure the date is valid ' blank - Makes sure the field contains at least one character ' numeric - Makes sure the field contains a numeric value ' IF THE RETURN VALUE IS TRUE, THE FIELD IS VALID. myValue=trim(myValue) Dim nonValid, hasChar ' Array of illegal characters for an email address nonValid = array(",", ";", ":", "'", "(", ")", "`", "[", "]", "#", "=", " ", "*", "<", ">", "?", "/", "\", "|", "$", "%", "{", "}", "!", """", "^") ' Flag used to determine if one of the illegal charcters was found in a given email address hasChar=0 SELECT CASE lcase(myValidate) CASE "regexp" ' use a regular expression select case cstr(myPattern) ' Pattern Types (or your own pattern) case "phone_1" myPattern="\d{3}-\d{3}-\d{4}$" myErr="- Phone Number must be in the format: xxx-xxx-xxxx" case "phone_2" myPattern="\(\d{3}\)\d{3}-\d{4}$" myErr="- Phone Number must be in the format: (xxx)xxx-xxxx" case "zip_1" myPattern="\d{5}$" myErr="- Zip code must be in the format: xxxxx" case "zip_2" myPattern="\d{5}-\d{4}$" myErr="- Zip code must be in the format: xxxxx-xxxx" case else myPattern=myPattern myErr="- Field did not match the pattern '" & myPattern & "'" end select Set RegularExpressionObject = New RegExp With RegularExpressionObject .Pattern = myPattern .IgnoreCase = True .Global = True End With validateField = RegularExpressionObject.Test(myValue) if validateField <> true then strError= strError & space(5) & myErr & vbcrlf end if Set RegularExpressionObject = nothing CASE "email" ' check for a valid email address if inStr(1,myValue,"@") <> 0 and inStr(1,myValue,".") <> 0 then theRest=right(myValue,Len(myValue)-inStr(1,myValue,"@")) if inStr(1,theRest,"@") <> 0 or right(myValue,1) = "@" or right(myValue,1) = "." or left(myValue,1) = "." or left(myValue,1) = "@" then validateField = false else if inStr(1,myValue,"@") = inStr(1,myValue,".")+1 or inStr(1,myValue,"@") = inStr(1,myValue,".")-1 then validateField = false elseif inStr(1,myValue,"..") <> 0 then validateField = false else for each x in nonValid if inStr(1,myValue,x) <> 0 then hasChar=1 end if next if hasChar=1 then validateField = false else validateField = true end if end if end if else validateField = false end if if validateField = false then strError= strError & space(5) & "- Email provided is not valid" & vbcrlf end if CASE "date" ' check to see if date is valid if isDate(myValue) then validateField = true else validateField = false strError= strError & space(5) & "- Date provided is not valid" & vbcrlf end if CASE "blank" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field cannot be left blank" & vbcrlf else validateField = true end if CASE "phonenum" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Phone number cannot be left blank" & vbcrlf else validateField = true end if CASE "thumbnail" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Thumbnail cannot be left blank" & vbcrlf else validateField = true end if CASE "gimage" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Gallery Image cannot be left blank" & vbcrlf else validateField = true end if CASE "price" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Price cannot be left blank" & vbcrlf else validateField = true end if CASE "bmsprice" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field BMS Price cannot be left blank" & vbcrlf else validateField = true end if CASE "shipcharge" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Shipcharges cannot be left blank" & vbcrlf else validateField = true end if CASE "bmsshipcharge" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field BMS Shipcharges cannot be left blank" & vbcrlf else validateField = true end if CASE "user" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field UserName cannot be left blank" & vbcrlf else validateField = true end if CASE "category" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Category cannot be left blank" & vbcrlf else validateField = true end if CASE "subcat1" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Sub Category 1 cannot be left blank" & vbcrlf else validateField = true end if CASE "subcat2" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Sub Category 2 cannot be left blank" & vbcrlf else validateField = true end if CASE "subcat3" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Sub Category 3 cannot be left blank" & vbcrlf else validateField = true end if CASE "ponum" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field PONum cannot be left blank" & vbcrlf else validateField = true end if CASE "firstname" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field First Name cannot be left blank" & vbcrlf else validateField = true end if CASE "lastname" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Last Name cannot be left blank" & vbcrlf else validateField = true end if CASE "city" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field City/Town of Residence cannot be left blank" & vbcrlf else validateField = true end if CASE "country" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Country of Residence cannot be left blank" & vbcrlf else validateField = true end if CASE "wid" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field WID cannot be left blank" & vbcrlf else validateField = true end if CASE "eid" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field EID cannot be left blank" & vbcrlf else validateField = true end if CASE "numberid" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field NUMBERID cannot be left blank" & vbcrlf else validateField = true end if CASE "numeric" ' check to see if value is numeric if isNumeric(myValue) then validateField = true else validateField = false strError= strError & space(5) & "- Field must be numeric" & vbcrlf end if CASE "passwordfield" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Password cannot be left blank" & vbcrlf else validateField = true end if CASE "confirmpasswordfield" ' check for blank field if myValue="" then validateField = false strError= strError & space(5) & "- Field Confirm Password cannot be left blank" & vbcrlf else validateField = true end if END SELECT end function