Form validation check | CODE { The say foundation | project }

//File Namevalidatorchklist.js
//============ Function to check field having no value ===============
function blankCheck(controlId,msg)
{
    if($('#'+controlId).val()=='')
    {
        // alert(msg);
        // alert(controlId);
        $('.errMsg_'+controlId).html(msg).show();
        $('#'+controlId).addClass('error-input');
        $('#'+controlId).focus();
        return false;
    }
    return true;
}

//____________________________________________________________________

//Blade page:
//employee Validate Message:
    let validateMsg = [];

    if (!blankCheck('employerName', 'Name can not be left blank'))
      validateMsg.push("Name can not be left blank");
      // return false;
    /* if (!blankCheck('employerName', 'Name can not be left blank'))
      return false; */

    if (!blankCheck('employerDesignation', 'Designation can not be left blank'))
      validateMsg.push("Designation can not be left blank");
      // return false;

    if (!blankCheck('employerCompany', 'Company Name can not be left blank'))
      validateMsg.push("Company Name can not be left blank");
      // return false;

    if (!blankCheck('employerWebsite', 'Company Website can not be left blank'))
      validateMsg.push("Company Website can not be left blank");
      // return false;

    /* if (!ValidURL($('#employerWebsite').val(), 'employerWebsite'))
      return false; */

    if (!blankCheck('employerLocation', 'Location can not be left blank'))
      validateMsg.push("Location can not be left blank");
      // return false;

    if (!blankCheck('selcity', 'City can not be left blank'))
      validateMsg.push("City can not be left blank");
      // return false;

    if (!selectDropdown('employerSkills', 'Please select a skill'))
      validateMsg.push("Please select a skill.");
      // return false;

    if (!selectDropdown('employerIndustry', 'Please select an Industry.'))
      validateMsg.push("Please select an Industry");
      // return false;

    if (!blankCheck('employerCompanyaddr', 'Company Address can not be left blank'))
      validateMsg.push("Company Address can not be left blank");

//____________________________________________________________________


if (validateMsg.length > 0 ) {
      $('.errshow').show();
        $('.errorMsg ol').html('');
          $.each(validateMsg, function(ErrKey,ErrVal) {
              $('.errorMsg ol').append('<li>'+ ErrVal + '.' +'</li>');
              /* $('.errorMsg ul').append(ErrVal);
              console.log(ErrVal);
              validateMsg.push('<li>'+ ErrVal +'</li>'); */
          });
        return false;
      } else {
              $('#employer-profile').submit();
      }


<!-- validation - 13-05-22 -->
    <div class="notification error closeable errshow">  
      <div class="errorMsg" id="errorMsg">
        <ol></ol>
      </div>
    </div>
<!-- end -->

Comments

Popular posts from this blog

C.R.U.D Oparetion in (PHP Code)

Search Dropdown - jQuery

JavaScript Form Validation Code