1// JavaScript Document 2//---formvalidations.js 3//---takes care of most form validations... 4 5//check the text value// 6function checkitem(item, fdesc) { 7 var errorstr = ""; 8 if (item.value == "" || checkblanks(item.value) == true) { 9 if (fdesc != "") { 10 errorstr = "'" + fdesc + "' is required.\n"; 11 } 12 } 13 return errorstr; 14 } 15 16// following looks for all blanks in a string - typical of checking// 17function checkblanks(item) { 18 var isblank = true; 19 for (i = 0; i < item.length; i++) { 20 if (item.charAt(i) != " ") { 21 isblank = false; } 22 } 23 return isblank; 24} 25 26// check for valid emails.... 27function checkemail(item) { 28 var goodmail = true; 29 var addr = item.value; 30 var invchar = " /:,;"; 31 var errorstr = ""; 32 var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ 33 var emailFilter=/^.+@.+\..{2,3}$/; 34 for (i=0; i<invchar.length; i++) { 35 badchar = invchar.charAt(i); 36 if (addr.indexOf(badchar,0) > -1) { 37 goodmail = false; 38 } 39 } 40 atpos = addr.indexOf("@",1); 41 if (atpos == -1) { 42 goodmail = false; 43 } 44 else { 45 perpos = addr.indexOf(".",atpos); 46 if (perpos == -1) { 47 goodmail = false; 48 } else if (perpos + 3 > addr.length) { 49 goodmail = false; 50 } else if (addr.match(illegalChars)) { 51 goodmail = false; 52 } else if (!(emailFilter.test(addr))) { 53 goodmail = false; 54 } 55 } 56 if (goodmail == false) { 57 errorstr = "Email address is not valid.\n"; 58 } 59 return errorstr; 60}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.