michael@0: letters = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); michael@0: numbers = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26); michael@0: colors = new Array("FF","CC","99","66","33","00"); michael@0: michael@0: var endResult; michael@0: michael@0: function doTest() michael@0: { michael@0: endResult = ""; michael@0: michael@0: // make up email address michael@0: /* BEGIN LOOP */ michael@0: for (var k=0;k<4000;k++) michael@0: { michael@0: name = makeName(6); michael@0: (k%2)?email=name+"@mac.com":email=name+"(at)mac.com"; michael@0: michael@0: // validate the email address michael@0: var pattern = /^[a-zA-Z0-9\-\._]+@[a-zA-Z0-9\-_]+(\.?[a-zA-Z0-9\-_]*)\.[a-zA-Z]{2,3}$/; michael@0: michael@0: if(pattern.test(email)) michael@0: { michael@0: var r = email + " appears to be a valid email address."; michael@0: addResult(r); michael@0: } michael@0: else michael@0: { michael@0: r = email + " does NOT appear to be a valid email address."; michael@0: addResult(r); michael@0: } michael@0: } michael@0: /* END LOOP */ michael@0: michael@0: // make up ZIP codes michael@0: /* BEGIN LOOP */ michael@0: for (var s=0;s<4000;s++) michael@0: { michael@0: var zipGood = true; michael@0: var zip = makeNumber(4); michael@0: (s%2)?zip=zip+"xyz":zip=zip.concat("7"); michael@0: michael@0: // validate the zip code michael@0: /* BEGIN LOOP */ michael@0: for (var i = 0; i < zip.length; i++) { michael@0: var ch = zip.charAt(i); michael@0: if (ch < "0" || ch > "9") { michael@0: zipGood = false; michael@0: r = zip + " contains letters."; michael@0: addResult(r); michael@0: } michael@0: } michael@0: /* END LOOP */ michael@0: if (zipGood && zip.length>5) michael@0: { michael@0: zipGood = false; michael@0: r = zip + " is longer than five characters."; michael@0: addResult(r); michael@0: } michael@0: if (zipGood) michael@0: { michael@0: r = zip + " appears to be a valid ZIP code."; michael@0: addResult(r); michael@0: } michael@0: } michael@0: /* END LOOP */ michael@0: } michael@0: michael@0: function makeName(n) michael@0: { michael@0: var tmp = ""; michael@0: /* BEGIN LOOP */ michael@0: for (var i=0;i