manage-account.js

About this file

On the manage account page, the function in this JS file creates restrictions on the input values and validates the keys using parsley. Users are restricted from entering non-numerical values into phone and fax fields. Character counts are added to fields.

data-parsley-required attributes are added to fields that are required, which are later validated. If required fields are missing values, the html is altered to include strong tags around the required fields.

Code Issues

  • The if statement below contains a mix of && and ||. Recommend creating a function that returns a boolean for the mailing address validation to simplify the if statement.
      
            if (email.parsley().isValid() ||
                phone.parsley().isValid() ||
                fax.parsley().isValid() ||
                (
                    // mailing address
                    address1.parsley().isValid() &&
                    state.parsley().isValid() &&
                    zip.parsley().isValid() &&
                    city.parsley().isValid()
                )
            ) {
      
      

Code Check Report




  67:54  warning  Function has a complexity of 9  complexity

✖ 1 problem (0 errors, 1 warning)
                        

Documentation drawn from source code

/**
* Created by atan on 9/22/16.
*/
$(document).ready(function () {
  phone.keypress(function(key) {
  fax.keypress(function(key) {
  title.keyup(function() {
  organization.keyup(function () {
  $("#request-form").parsley().on("form:validate", function () {

Source code