1px solid red fieldsetValidity false else currentElement style border if

1px solid red fieldsetvalidity false else

This preview shows page 54 - 57 out of 84 pages.

"1px solid red" ; fieldsetValidity = false ; } else { currentElement . style . border = "" ; } } if ( cvvElement . value === "" ) { // verify that a cvv value has been entered cvvElement . style . background = "rgb(255,233,233)" ; fieldsetValidity = false ; } else { cvvElement . style . background = "white" ; } if (! fieldsetValidity ) { // check if any field is blank throw "Please complete all payment information." ; } else { errorDiv . style . display = "none" ; } } catch ( msg ) { errorDiv . style . display = "block" ; errorDiv . innerHTML = msg ; formValidity = false ; } } /* validate message fieldset */ function validateMessage () { var errorDiv = document . querySelector ( "#message .errorMessage" ); var msgBox = document . getElementById ( "customText" ); try { if ( document . getElementById ( "custom" ). checked && (( msgBox . value === "" ) || ( msgBox . value === msgBox . placeholder ))) { // custom checked but message box empty throw "Please enter your message text." ; } else { errorDiv . style . display = "none" ; msgBox . style . background = "white" ; } } catch ( msg ) { errorDiv . style . display = "block" ; errorDiv . innerHTML = msg ; msgBox . style . background = "rgb(255,233,233)" ; formValidity = false ; } } /* validate create account fieldset */ function validateCreateAccount () { var errorDiv = document . querySelector ( "#createAccount .errorMessage" ); var usernameElement = document . getElementById ( "username" ); var pass1Element = document . getElementById ( "pass1" ); var pass2Element = document . getElementById ( "pass2" ); var passwordMismatch = false ; var invColor = "rgb(255,233,233)" ;
Image of page 54
S t u d e n t N u m b e r : 3 5 5 0 5 1 0 9 U n i q u e N u m b e r : 8 4 7 1 1 4 P a g e 55 | 84 try { // reset styles to valid state usernameElement . style . background = "" ; pass1Element . style . background = "" ; pass2Element . style . background = "" ; errorDiv . style . display = "none" ; if (( usernameElement . value !== "" && pass1Element . value !== "" && pass2Element . value !== "" )) { // all fields are filled if ( pass1Element . value !== pass2Element . value ) { // passwords don't match passwordMismatch = true ; throw "Passwords entered do not match; please reenter." ; } } if ( usernameElement . value === "" && pass1Element . value === "" && pass2Element . value === "" ) { // not all fields are blank throw "Please complete all fields to create an account." ; } } catch ( msg ) { errorDiv . innerHTML = msg ; errorDiv . style . display = "block" ; if ( passwordMismatch ) { usernameElement . style . background = "" ; pass1Element . style . background = invColor ; pass2Element . style . background = invColor ; } else { if ( usernameElement . value === "" ) { usernameElement . style . background = invColor ; } if ( pass1Element . value === "" ) { pass1Element . style . background = invColor ; } if ( pass2Element . value === "" ) { pass2Element . style . background = invColor ; } } formValidity = false ; } } function validateNumbers () { var ccNotNum ; var cvvNotNum ; var ccNumElement = document . getElementById ( "ccNum" ); var cvvElement = document . getElementById ( "cvv" ); var ccNumErrMsg = document . getElementById ( "ccNumErrorMessage" ); var cvvErrMsg = document . getElementById ( "cvvErrorMessage" ); try { if ( isNaN ( ccNumElement . value ) || ccNumElement . value === "" ) { ccNotNum = true ; } else { // ccNum value is a number ccNumElement . style . background = "" ; ccNumErrMsg . style . display = "none" ; }
Image of page 55
S t u d e n t N u m b e r : 3 5 5 0 5 1 0 9 U n i q u e N u m b e r : 8 4 7 1 1 4 P a g e 56 | 84 if ( isNaN ( cvvElement . value ) || cvvElement . value === "" ) { cvvNotNum = true ; } else { // cvv value is a number cvvElement . style . background = "" ; cvvErrMsg . style . display = "none" ; } if ( ccNotNum || cvvNotNum ) { throw "must contain numbers only." ; } } catch ( msg ) { if ( ccNotNum ) { ccNumElement . style .
Image of page 56
Image of page 57

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture