How to use firstError method in wpt

Best JavaScript code snippet using wpt

user.js

Source:user.js Github

copy

Full Screen

1//functions2function isNumber(c) {3 var pattern = /[0-9]/;4 if (pattern.test(c)) {5 return true;6 }7 else {8 return false;9 }10}11function isLowerCase(c) {12 var pattern = /[a-z]/;13 if (pattern.test(c)) {14 return true;15 }16 else {17 return false;18 }19}20function isUpperCase(c) {21 var pattern = /[A-Z]/;22 if (pattern.test(c)) {23 return true;24 }25 else {26 return false;27 }28}29function isSpecial(c) {30 var pattern = /[~!@#$%^&*()_+|<>?:{}]/;31 if (pattern.test(c)) {32 return true;33 }34 else {35 return false;36 }37}38function isKorean(c) {39 var pattern = /[가-힣]/;40 if (pattern.test(c)) {41 return true;42 }43 else {44 return false;45 }46}47function isSpace(c) {48 var pattern = /\s/;49 if (pattern.test(c)) {50 return true;51 }52 else {53 return false;54 }55}56function isEmail(string) {57 var pattern = /^[A-Za-z0-9_\.\-]+@[A-Za-z0-9\-]+\.[A-Za-z0-9\-]/;58 if (pattern.test(string)) {59 return true;60 }61 else {62 return false;63 }64}65function isValid(string, number, lowerCase, upperCase, special, korean, space) {66 var cnt = 0;67 for (var i = 0; i < string.length; i++) {68 var c = string.charAt(i);69 if (number && isNumber(c)) {70 cnt++;71 }72 if (lowerCase && isLowerCase(c)) {73 cnt++;74 }75 if (upperCase && isUpperCase(c)) {76 cnt++;77 }78 if (special && isSpecial(c)) {79 cnt++;80 }81 if (korean && isKorean(c)) {82 cnt++;83 }84 if (space && isSpace(c)) {85 cnt++;86 }87 }88 if (cnt == string.length) {89 return true;90 }91 else {92 return false;93 }94}95function lengthBetween(string, min, max) {96 if (min == "" && max == "") {97 return true;98 }99 else if (min == "") {100 if (string.length <= max) {101 return true;102 }103 else {104 return false;105 }106 }107 else if (max == "") {108 if (min <= string.length) {109 return true;110 }111 else {112 return false;113 }114 }115 else {116 if (min <= string.length && string.length <= max) {117 return true;118 }119 else {120 return false;121 }122 }123}124function clearError(id) {125 document.getElementById(id + "Error").innerHTML = "";126}127//edit info128function editInfoConfirm() {129 var firstError = true;130 //check nickname131 var nickname = document.getElementById("nicknameInput");132 var nicknameError = document.getElementById("nicknameInputError");133 var nicknameValid = isValid(nickname.value, true, true, true, false, true, false) && lengthBetween(nickname.value, 2, 10);134 var nicknameList = ["admin", "user"]135 var isExist = nicknameList.includes(nickname.value);136 if (!nicknameValid) {137 nicknameError.innerHTML = "닉네임은 특수문자와 공백을 제외한 2~10글자로 입력해주세요.";138 if (firstError) {139 nickname.focus();140 firstError = false;141 }142 }143 if (nickname.value.length == 0) {144 nicknameError.innerHTML = "닉네임을 입력해 주세요";145 if (firstError) {146 nickname.focus();147 firstError = false;148 }149 }150 //check email151 var email = document.getElementById("emailInput");152 var emailError = document.getElementById("emailInputError");153 var emailValid = isEmail(email.value);154 if (!emailValid) {155 emailError.innerHTML = "이메일 형식이 올바르지 않습니다.";156 if (firstError) {157 email.focus();158 firstError = false;159 }160 }161 if (isExist) {162 nicknameError.innerHTML = "중복된 닉네임 입니다.";163 if (firstError) {164 nickname.focus();165 firstError = false;166 }167 }168 if (email.value.length == 0) {169 emailError.innerHTML = "이메일을 입력해 주세요";170 if (firstError) {171 email.focus();172 firstError = false;173 }174 }175 //no information has changed176 if(nickname.value=="admin123" && email.value=="admin@email.com"){177 alert("변경된 내용이 없습니다.");178 return;179 }180 //confirm181 if (firstError == true) {182 alert("회원정보 변경이 완료되었습니다.")183 }184}185//signup button186function signupConfirm() {187 var firstError = true;188 //check name189 var name = document.getElementById("nameInput");190 var nameError = document.getElementById("nameInputError");191 var nameValid = isValid(name.value, false, false, false, false, true, false) && lengthBetween(name.value, 2, 5);192 if (!nameValid) {193 nameError.innerHTML = "이름은 2~5글자 한글로 입력해주세요.";194 if (firstError) {195 name.focus();196 firstError = false;197 }198 }199 if (name.value.length == 0) {200 nameError.innerHTML = "이름을 입력해 주세요."201 if (firstError) {202 name.focus();203 firstError = false;204 }205 }206 //check id207 var id = document.getElementById("idInput");208 var idError = document.getElementById("idInputError");209 var idValid = isValid(id.value, true, true, true, false, false, false) && lengthBetween(id.value, 4, 10);210 var idList = ["admin", "user"]211 var isExist = idList.includes(id.value);212 if (!idValid) {213 idError.innerHTML = "아이디는 영어와 숫자만을 혼용하여 공백없이 4~10자로 입력해주세요.";214 if (firstError) {215 id.focus();216 firstError = false;217 }218 }219 if (isExist) {220 idError.innerHTML = "중복된 아이디 입니다.";221 if (firstError) {222 id.focus();223 firstError = false;224 }225 }226 if (id.value.length == 0) {227 idError.innerHTML = "아이디를 입력해 주세요";228 if (firstError) {229 id.focus();230 firstError = false;231 }232 }233 234 //check nickname235 var nickname = document.getElementById("nicknameInput");236 var nicknameError = document.getElementById("nicknameInputError");237 var nicknameValid = isValid(nickname.value, true, true, true, false, true, false) && lengthBetween(nickname.value, 2, 10);238 var nicknameList = ["admin", "user"]239 var isExist = nicknameList.includes(nickname.value);240 if (!nicknameValid) {241 nicknameError.innerHTML = "닉네임은 특수문자와 공백을 제외한 2~10글자로 입력해주세요.";242 if (firstError) {243 nickname.focus();244 firstError = false;245 }246 }247 if (isExist) {248 nicknameError.innerHTML = "중복된 닉네임 입니다.";249 if (firstError) {250 nickname.focus();251 firstError = false;252 }253 }254 if (nickname.value.length == 0) {255 nicknameError.innerHTML = "닉네임을 입력해 주세요";256 if (firstError) {257 nickname.focus();258 firstError = false;259 }260 }261 //check email262 var email = document.getElementById("emailInput");263 var emailError = document.getElementById("emailInputError");264 var emailValid = isEmail(email.value);265 if (!emailValid) {266 emailError.innerHTML = "이메일 형식이 올바르지 않습니다.";267 if (firstError) {268 email.focus();269 firstError = false;270 }271 }272 if (email.value.length == 0) {273 emailError.innerHTML = "이메일을 입력해 주세요";274 if (firstError) {275 email.focus();276 firstError = false;277 }278 }279 //check password280 var password = document.getElementById("passwordInput");281 var passwordError = document.getElementById("passwordInputError");282 var passwordValid = isValid(password.value, true, true) && lengthBetween(password.value, 8, "");283 if (!passwordValid) {284 passwordError.innerHTML = "비밀번호는 공백 없이 8자리 이상으로 입력해 주세요.";285 if (firstError) {286 password.focus();287 firstError = false;288 }289 }290 if (password.value.length == 0) {291 passwordError.innerHTML = "비밀번호를 입력해 주세요";292 if (firstError) {293 password.focus();294 firstError = false;295 }296 }297 //check password check298 var passwordCheck = document.getElementById("passwordCheckInput");299 var passwordCheckError = document.getElementById("passwordCheckInputError");300 var passwordCheckValid = (password.value == passwordCheck.value);301 if (!passwordCheckValid) {302 passwordCheckError.innerHTML = "비밀번호가 일치하지 않습니다.";303 if (firstError) {304 passwordCheck.focus();305 firstError = false;306 }307 }308 if (passwordCheck.value.length == 0) {309 passwordCheckError.innerHTML = "비밀번호를 한번 더 입력해 주세요";310 if (firstError) {311 passwordCheck.focus();312 firstError = false;313 }314 }315 //confirm316 if (firstError == true) {317 alert("회원가입을 축하합니다.");318 $('#popup_content').load("/html/MEM/login.html");319 modal.style.display = "block";320 }321}322//terms button323function termsConfirm() {324 if (document.getElementById("termsOfService").checked == false) {325 alert("하루,단어 이용 약관에 동의하셔야 회원가입을 하실 수 있습니다.");326 document.getElementById("termsOfService").focus();327 return;328 }329 if (document.getElementById("privacyPolicy").checked == false) {330 alert("하루,단어 개인정보 처리방침에 동의하셔야 회원가입을 하실 수 있습니다.");331 document.getElementById("privacyPolicy").focus();332 return;333 }334 //confirm335 $('#popup_content').load("/html/MEM/signup.html");336 modal.style.display = "block";337}338//login button339function loginConfirm(){340 var firstError = true;341 //check id342 var id = document.getElementById("idInput");343 var idError = document.getElementById("idInputError");344 if (id.value.length == 0) {345 idError.innerHTML = "아이디를 입력해 주세요";346 if (firstError) {347 id.focus();348 firstError = false;349 }350 }351 //check password352 var password = document.getElementById("passwordInput");353 var passwordError = document.getElementById("passwordInputError");354 if (password.value.length == 0) {355 passwordError.innerHTML = "비밀번호를 입력해 주세요";356 if (firstError) {357 password.focus();358 firstError = false;359 }360 }361 //check if id and password are valid362 var idList = ["admin", "user"]363 var pwList = ["adminpassword","userpassword"]364 var loginConfirm=false;365 366 if(idList.includes(id.value)&&pwList.includes(password.value)){367 if(idList.indexOf(id.value)==pwList.indexOf(password.value)){368 loginConfirm=true;369 };370 };371 //confirm372 if (firstError == true && loginConfirm) {373 window.location.href = "/index.html";374 }375 else if(firstError == true){376 alert("가입하지 않은 아이디이거나, 잘못된 비밀번호입니다.");377 }378}379//find id button380function forgotIdConfirm(){381 var firstError = true;382 //check name383 var name = document.getElementById("nameInput");384 var nameError = document.getElementById("nameInputError");385 var nameList = ["장세진","정현우"]386 //var isExist = nameList.includes(name.value);387 // if (!isExist) {388 // nameError.innerHTML = "존재하지 않는 이름입니다.";389 // if (firstError) {390 // name.focus();391 // firstError = false;392 // }393 // }394 if (name.value.length == 0) {395 nameError.innerHTML = "이름을 입력해 주세요."396 if (firstError) {397 name.focus();398 firstError = false;399 }400 }401 //check email402 var email = document.getElementById("emailInput");403 var emailError = document.getElementById("emailInputError");404 var emailValid = isEmail(email.value);405 var emailList = ["sae0817@naver.com","jhw123@naver.com"]406 var isExist = emailList.includes(email.value);407 408 // if (!isExist) {409 // emailError.innerHTML = "존재하지 않는 이메일 입니다";410 // if (firstError) {411 // email.focus();412 // firstError = false;413 // }414 // }415 if (!emailValid) {416 emailError.innerHTML = "이메일 형식이 올바르지 않습니다.";417 if (firstError) {418 email.focus();419 firstError = false;420 }421 }422 if (email.value.length == 0) {423 emailError.innerHTML = "이메일을 입력해 주세요";424 if (firstError) {425 email.focus();426 firstError = false;427 }428 }429 //check if name and email are valid430 var findIdConfirm=false;431 if(nameList.includes(name.value)){432 if(nameList.indexOf(name.value)==emailList.indexOf(email.value)){433 findIdConfirm=true;434 };435 };436 //id database437 var idList = ["admin", "user"]438 //confirm439 if (firstError == true && findIdConfirm) {440 alert("고객님의 아이디는 '" + idList[nameList.indexOf(name.value)] + "' 입니다.");441 $('#popup_content').load("/html/MEM/login.html");442 modal.style.display = "block";443 }444 else if (firstError == true) {445 alert("입력하신 정보를 찾을 수 없습니다.")446 }447}448//find password button449function forgotPwConfirm(){450 var firstError = true;451 //check name452 var name = document.getElementById("nameInput");453 var nameError = document.getElementById("nameInputError");454 var nameList = ["장세진","정현우"]455 //var isExist = nameList.includes(name.value);456 // if (!isExist) {457 // nameError.innerHTML = "존재하지 않는 이름입니다.";458 // if (firstError) {459 // name.focus();460 // firstError = false;461 // }462 // }463 if (name.value.length == 0) {464 nameError.innerHTML = "이름을 입력해 주세요."465 if (firstError) {466 name.focus();467 firstError = false;468 }469 }470 //check id471 var id = document.getElementById("idInput");472 var idError = document.getElementById("idInputError");473 var idList = ["admin", "user"]474 var isExist = idList.includes(id.value);475 476 // if (!isExist) {477 // idError.innerHTML = "존재하지 않는 아이디 입니다";478 // if (firstError) {479 // id.focus();480 // firstError = false;481 // }482 // }483 if (id.value.length == 0) {484 idError.innerHTML = "아이디를 입력해 주세요";485 if (firstError) {486 id.focus();487 firstError = false;488 }489 }490 //check email491 var email = document.getElementById("emailInput");492 var emailError = document.getElementById("emailInputError");493 var emailValid = isEmail(email.value);494 var emailList = ["sae0817@naver.com","jhw123@naver.com"]495 var isExist = emailList.includes(email.value);496 497 // if (!isExist) {498 // emailError.innerHTML = "존재하지 않는 이메일 입니다";499 // if (firstError) {500 // email.focus();501 // firstError = false;502 // }503 // }504 if (!emailValid) {505 emailError.innerHTML = "이메일 형식이 올바르지 않습니다.";506 if (firstError) {507 email.focus();508 firstError = false;509 }510 }511 if (email.value.length == 0) {512 emailError.innerHTML = "이메일을 입력해 주세요";513 if (firstError) {514 email.focus();515 firstError = false;516 }517 }518 //check if name and id and email are valid519 var findPwConfirm=false;520 if(nameList.includes(name.value)){521 if(nameList.indexOf(name.value)==idList.indexOf(id.value)&&idList.indexOf(id.value)==emailList.indexOf(email.value)){522 findPwConfirm=true;523 };524 };525 //confirm526 if (firstError == true && findPwConfirm) {527 alert("고객님의 임시 비밀번호를 이메일로 보내드렸습니다.");528 $('#popup_content').load("/html/MEM/login.html");529 modal.style.display = "block";530 }531 else if (firstError == true) {532 alert("입력하신 정보를 찾을 수 없습니다.")533 }534 else{535 }536}537//check password button538function checkPwConfirm(){539 var firstError = true;540 //check password541 var password = document.getElementById("passwordInput");542 var passwordError = document.getElementById("passwordInputError");543 if (password.value.length == 0) {544 passwordError.innerHTML = "비밀번호를 입력해 주세요";545 if (firstError) {546 password.focus();547 firstError = false;548 }549 }550 //check if password is valid551 var pwList = ["adminpassword","userpassword"]552 var loginConfirm=false;553 if(pwList.includes(password.value)){554 //if(idList.indexOf(id.value)==pwList.indexOf(password.value)){555 loginConfirm=true;556 //};557 };558 //confirm559 if (firstError == true && loginConfirm) {560 window.location.href = "/html/MYP/editInfo.html";561 }562 else if(firstError == true){563 alert("비밀번호가 일치하지 않습니다.");564 }565}566//change password button567function changePwConfirm(){568 var firstError = true;569 //old check password570 var oldPassword = document.getElementById("oldPasswordInput");571 var oldPasswordError = document.getElementById("oldPasswordInputError");572 if (oldPassword.value.length == 0) {573 oldPasswordError.innerHTML = "현재 비밀번호를 입력해 주세요";574 if (firstError) {575 oldPassword.focus();576 firstError = false;577 }578 }579 //check if password is valid580 var pwList = ["adminpassword","userpassword"]581 var passwordConfirm=false;582 if(pwList.includes(oldPassword.value)){583 //if(idList.indexOf(id.value)==pwList.indexOf(password.value)){584 passwordConfirm=true;585 //};586 };587 //new check password588 var newPassword = document.getElementById("newPasswordInput");589 var newPasswordError = document.getElementById("newPasswordInputError");590 var newPasswordValid = isValid(newPassword.value, true, true, true, true, false, false) && lengthBetween(newPassword.value, 8, "");591 if (oldPassword.value == newPassword.value) {592 newPasswordError.innerHTML = "현재 비밀번호와 새 비밀번호를 다르게 입력해주세요.";593 if (firstError) {594 newPassword.focus();595 firstError = false;596 }597 }598 if (!newPasswordValid) {599 newPasswordError.innerHTML = "비밀번호는 공백 없이 8자리 이상으로 입력해 주세요.";600 if (firstError) {601 newPassword.focus();602 firstError = false;603 }604 }605 if (newPassword.value.length == 0) {606 newPasswordError.innerHTML = "새 비밀번호를 입력해 주세요";607 if (firstError) {608 newPassword.focus();609 firstError = false;610 }611 }612 //check password check613 var newPasswordCheck = document.getElementById("newPasswordCheckInput");614 var newPasswordCheckError = document.getElementById("newPasswordCheckInputError");615 var newPasswordCheckValid = (newPassword.value == newPasswordCheck.value);616 if (!newPasswordCheckValid) {617 newPasswordCheckError.innerHTML = "비밀번호가 일치하지 않습니다.";618 if (firstError) {619 newPasswordCheck.focus();620 firstError = false;621 }622 }623 if (newPasswordCheck.value.length == 0) {624 newPasswordCheckError.innerHTML = "새 비밀번호 확인을 입력해 주세요";625 if (firstError) {626 newPasswordCheck.focus();627 firstError = false;628 }629 }630 //confirm631 if (firstError == true && passwordConfirm) {632 alert("비밀번호 변경이 완료되었습니다.");633 window.location.href = "/html/MYP/editInfo.html";634 }635 else if(firstError == true){636 alert("현재 비밀번호가 일치하지 않습니다.");637 }638}639//delete account button640function deleteAccountConfirm(){641 var firstError = true;642 //check password643 var password = document.getElementById("passwordInput");644 var passwordError = document.getElementById("passwordInputError");645 if (password.value.length == 0) {646 passwordError.innerHTML = "비밀번호를 입력해 주세요";647 if (firstError) {648 password.focus();649 firstError = false;650 }651 } 652 //check if id and password are valid653 var pwList = ["adminpassword","userpassword"]654 var loginConfirm=false;655 if(pwList.includes(password.value)){656 //if(idList.indexOf(id.value)==pwList.indexOf(password.value)){657 loginConfirm=true;658 //};659 };660 //confirm661 if (firstError == true && loginConfirm) {662 alert("회원탈퇴가 완료되었습니다.");663 window.location.href = "/index.html";664 }665 else if(firstError == true){666 alert("비밀번호가 일치하지 않습니다.");667 }...

Full Screen

Full Screen

deciders.test.ts

Source:deciders.test.ts Github

copy

Full Screen

1import * as path from "path";2import { compile } from "./utilities";3import CONFIG_WITH from "./webpack.config";4import * as deciders from "../src/deciders";5describe("Deciders", () => {6 jest.setTimeout(30000);7 it("should restrict imports correctly with everythingOutside", done => {8 compile(9 CONFIG_WITH({10 entry: "relative.ts",11 severity: "error",12 restricted: deciders.everythingOutside([13 path.resolve(__dirname, "src"),14 path.resolve(__dirname, "..", "node_modules"),15 ]),16 }),17 (stats, compilation) => {18 expect(stats.hasErrors()).toBe(true);19 expect(compilation.errors).toHaveLength(1);20 const firstError = compilation.errors[0];21 expect(firstError).toBeInstanceOf(Error);22 expect(firstError.name).toBe(`ModuleError`);23 expect(firstError.message.match(/•/g)).toHaveLength(2);24 expect(firstError.message).toMatch(`import * as coretest1 from "../core.test";`);25 expect(firstError.message).toMatch(`import * as coretest2 from "./../core.test";`);26 expect(firstError.message).not.toMatch(`import * as functions1 from "./functions";`);27 expect(firstError.message).not.toMatch(`import * as functions2 from "../src/functions";`);28 expect(firstError.message).not.toMatch(`import * as typescript from "typescript";`);29 done();30 }31 );32 });33 it("should restrict imports correctly with everythingInside", done => {34 compile(35 CONFIG_WITH({36 entry: "relative.ts",37 severity: "error",38 restricted: deciders.everythingInside([39 path.resolve(__dirname, "src"),40 path.resolve(__dirname, "..", "node_modules"),41 ]),42 }),43 (stats, compilation) => {44 expect(stats.hasErrors()).toBe(true);45 expect(compilation.errors).toHaveLength(1);46 const firstError = compilation.errors[0];47 expect(firstError).toBeInstanceOf(Error);48 expect(firstError.name).toBe(`ModuleError`);49 expect(firstError.message.match(/•/g)).toHaveLength(3);50 expect(firstError.message).toMatch(`import * as functions1 from "./functions";`);51 expect(firstError.message).toMatch(`import * as functions2 from "../src/functions";`);52 expect(firstError.message).toMatch(`import * as typescript from "typescript";`);53 expect(firstError.message).not.toMatch(`import * as coretest1 from "../core.test";`);54 expect(firstError.message).not.toMatch(`import * as coretest2 from "./../core.test";`);55 done();56 }57 );58 });59 it("should restrict imports correctly with climbingUpwardsMoreThan", done => {60 compile(61 CONFIG_WITH({62 entry: "climbing-upwards.ts",63 severity: "error",64 restricted: deciders.climbingUpwardsMoreThan(1),65 }),66 (stats, compilation) => {67 expect(stats.hasErrors()).toBe(true);68 expect(compilation.errors).toHaveLength(1);69 const firstError = compilation.errors[0];70 expect(firstError).toBeInstanceOf(Error);71 expect(firstError.name).toBe(`ModuleError`);72 expect(firstError.message.match(/•/g)).toHaveLength(8);73 expect(firstError.message).toMatch(`import {} from "../../src";`);74 expect(firstError.message).toMatch(`import {} from "./../../src";`);75 expect(firstError.message).toMatch(`import {} from "../../src/loader";`);76 expect(firstError.message).toMatch(`import {} from ".././../src/loader";`);77 expect(firstError.message).toMatch(`import {} from "./.././../src/loader";`);78 expect(firstError.message).toMatch(`import {} from "../../__tests__/src/functions";`);79 expect(firstError.message).toMatch(`import {} from "../src/../../__tests__/src/functions";`);80 expect(firstError.message).toMatch(`import {} from "typescript/lib/../../typescript/lib/typescript";`);81 expect(firstError.message).toMatch(`(contains 2 consecutive occurrences of "../"; max 1 allowed)`);82 expect(firstError.message).not.toMatch(`import {} from "typescript";`);83 expect(firstError.message).not.toMatch(`import {} from "./functions";`);84 expect(firstError.message).not.toMatch(`import {} from "../webpack.config";`);85 expect(firstError.message).not.toMatch(`import {} from "./../webpack.config";`);86 expect(firstError.message).not.toMatch(`import {} from "../src/functions";`);87 done();88 }89 );90 });...

Full Screen

Full Screen

termination.js

Source:termination.js Github

copy

Full Screen

1function verify(f)2{3 var fieldCount = 62;4 var rField = new Array(fieldCount);5 rField[0] = "Employee Number";6 rField[1] = "Date Issued";7 for(var i = 2; i < 56; i++)8 {9 rField[i] = "";10 }11 rField[56] = "Employee Signature";12 rField[57] = "Trainer Signature";13 rField[58] = "Supervisor Signature"14 rField[59] = "Employee Signature Date";15 rField[60] = "Trainer Signature Date";16 rField[61] = "Supervisor Signature Date";17 var firstError = false;18 var errorField;19 var blankCheck = false;20 21 var checkCount = 0;22 alert("Check count: " + checkCount);23 for(var i = 0; i < f.length; i++)24 {25 var e = f.elements[i];26 //alert(rField[i] + " is type: " + e.type);27 if(e.type == "text")28 {29 if((e.value == null) || (e.value == ""))// || isblank(e))30 {31 blankCheck = true;32 }33 else34 {35 blankCheck = false;36 }37 if(e.required == true)// && e.getAttribute("optional") == null)38 {39 alert(rField[i] + " is required");40 alert("Blank Check is " + blankCheck);41 if(blankCheck == true)42 {43 errors = true;44 if(!firstError)45 {46 errorField = e;47 alert(i + ". Please enter the " + rField[i]);48 errorField.focus();49 firstError = true;50 }51 continue;52 }53 else54 {55 alert(rField[i] + " is not blank");56 alert("Date Check: " + e.dateCheck);57 if(e.dateCheck)58 {59 alert(rField[i] + " must be a date");60 //firstError = checkDateFormat(e, rField[i], firstError);61 }62 63 if(e.numberTest == true || e.numeric == true)64 {65 alert("Number Test");66 firstError = checkNumber(e, rField[i], firstError);67 }68 69 //if(70 }71 }72 else73 {74 alert("Field " + i + " is optional");75 if(e.dateCheck)76 {77 alert(rField[i] + " must be a date");78 //firstError = checkDateFormat(e, rField, firstError);79 }80 81 if(e.numberTest == true || e.numeric == true)82 {83 alert("Number Test");84 firstError = checkNumber(e, rField[i], firstError);85 }86 }87 }88 }89 90 if(firstError)91 {92 errors = true;93 errorField = e;94 }95 96 if(!errors)97 return true;98 else99 return false;100}101function checkDateFormat(e, fieldName, firstError)102{103 var v = e.value;104 var dateFormat = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;105 if(!dateFormat.test(v))106 {107 alert("The " + fieldName + " must be in the following format: mm-dd-yyyy");108 e.focus();109 firstError = true;110 }111 112 return firstError;113}114function numericTest(e, fieldName, firstError)115{116 var v = e.value;117 if (isNaN(v))118 {119 if (!firstError)120 {121 alert("The " + fieldName + " must be numeric.");122 e.focus();123 firstError = true;124 }125 }126 return firstError;127}128 129function checkNumber(empNum, fieldName, firstError)130{131 //alert(empNum);132 var xmlhttp;133 var deptName = empNum.value;134 //alert(deptName);135 //return firstError;136 if(window.XMLHttpRequest)137 {138 //code for IE7+, Firefox, Chrome, Opera, Safari139 xmlhttp=new XMLHttpRequest();140 }141 else142 {143 //code for IE6, IE5144 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");145 }146 xmlhttp.onreadystatechange = function()147 {148 if(xmlhttp.readyState == 4 && xmlhttp.status == 200)149 {150 var numExists = xmlhttp.responseText;151 if(numExists == "false")152 {153 document.getElementById(fieldName).style.color = "red";154 alert("The employee number you entered does not exist");155 empNum.focus();156 firstError = true;157 }158 else159 {160 161 firstError = false;162 }163 return firstError;164 }165 }166 //&#38; - ampersand167 xmlhttp.open('GET', 'processes/get_skils.php?dept='+dept, true);168 xmlhttp.send();*/...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log('Test status: ' + data.statusText);7 wpt.firstView(data.data.testId, function(err, data) {8 if (err) {9 console.log('Error: ' + err);10 } else {11 console.log('First View: ' + data.statusText);12 }13 });14 }15});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5 if (err) return console.error(err);6 var testId = data.data.testId;7 wpt.getTestResults(testId, function(err, data) {8 if (err) return console.error(err);9 console.log(data.data.runs[1].firstView);10 });11});12var wpt = require('webpagetest');13var wpt = new WebPageTest('www.webpagetest.org');14var options = {15};16 if (err) return console.error(err);17 var testId = data.data.testId;18 wpt.getTestResults(testId, function(err, data) {19 if (err) return console.error(err);20 console.log(data.data.runs[1].firstView);21 });22});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var wp = new wptoolkit();3 console.log(error);4});5var wptoolkit = require('wptoolkit');6var wp = new wptoolkit();7 console.log(error);8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var firstError = require('wptoolbox').firstError;2var error = firstError([1,2,3,4,5,6,7,8,9,10], function(n) {3 return n > 5;4});5var firstError = require('wptoolbox').firstError;6var error = firstError([1,2,3,4,5,6,7,8,9,10], function(n) {7 return n > 10;8});9var firstError = require('wptoolbox').firstError;10var error = firstError([1,2,3,4,5,6,7,8,9,10], function(n) {11 return n > 5;12});13var firstError = require('wptoolbox').firstError;14var error = firstError([1,2,3,4,5,6,7,8,9,10], function(n) {15 return n > 10;16});17var firstError = require('wptoolbox').firstError;18var error = firstError([1,2,3,4,5,6,7,8,9,10], function(n) {19 return n > 5;20});21var firstError = require('wptoolbox').firstError;22var error = firstError([1,2,3,4,5,6,7,8,9,10], function(n) {23 return n > 10;24});25var firstError = require('wptoolbox').firstError;26var error = firstError([1,2,3

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wptTest = new wpt('API_KEY');3var options = {4};5wptTest.runTest(options, function(err, data){6 if(err){7 console.log(err);8 }else{9 console.log(data);10 wptTest.firstError(data.data.runs[1].firstView, function(err, data){11 if(err){12 console.log(err);13 }else{14 console.log(data);15 }16 });17 }18});19var wpt = require('webpagetest');20var wptTest = new wpt('API_KEY');21var options = {22};23wptTest.runTest(options, function(err, data){24 if(err){25 console.log(err);26 }else{27 console.log(data);28 wptTest.firstViewData(data.data.runs[1].firstView, function(err, data){29 if(err){30 console.log(err);31 }else{32 console.log(data);33 }34 });35 }36});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful