Search
 
SCRIPT & CODE EXAMPLE
 

PHP

dependable validation in laravel

 'nriq'          => 'required',
            'nrim'          => 'required_if:nriq,Yes',
//multiple
  'cate'          => 'required',
   'ncl_cert' => 'required_if:cate,DT-VJ(A),NT(B),NT(D),OBC,SBC',
Comment

dependable validation in laravel

              $('#formid').validate({
                  rules: {
                      inservice_quota: "required",
                      inservice_jion_date: {
                          required: function () {
                              if ($('#idofpreviousfield').val() === 'Yes') {
                                  return true;
                              } else {
                                  return false;
                              }
                          },
                      },
                      inservice_posting_addr: {
                          required: function () {
                              if ($('#InserviceQuota').val() === 'Yes') {
                                  return true;
                              } else {
                                  return false;
                              }
                          },
                      },
                      inservice_establish_noc:{
                          required: function () {
                              if ($('#InserviceQuota').val() === 'Yes') {
                                  return true;
                              } else {
                                  return false;
                              }
                          },
                      },
                      inservice_establish_noc_date:{
                          required: function () {
                              if ($('#Noc').val() === 'Yes') {
                                  return true;
                              } else {
                                  return false;
                              }
                          },
                      },
                      inservice_dept_enquiry:{
                          required: function () {
                              if ($('#InserviceQuota').val() === 'Yes') {
                                  return true;
                              } else {
                                  return false;
                              }
                          },
                      }
                  },
                  messages: {
                      inservice_quota:{
                        required :"Please Select Inservice Quota"
                      },
                      inservice_jion_date:{
                          required :"Please select Date of Joining Permanent Service"
                      },
      
                  },
                  submitHandler: function (form) {

                      var action = "{{ route('Quota.store') }}";

                      $.ajax({
                          url: action,
                          data: $(form).serialize(),
                          type: 'post',
                          success: function (result) {
                              console.log(result.status);
                              if (result.status == "success") {
                                  toastr.success(result.msg);
                              }
                          },
                          error: function (response) {
                              let data = response.responseJSON.errors;
                              if (data) {
                                  $.each(data, function (index, jsonObject) {
                                      $.each(jsonObject, function (key, val) {
                                          console.log(val);
                                          toastr.error(val);
                                      });
                                      return false;
                                  });
                              }
                          }
                      });
                  }
              });
Comment

PREVIOUS NEXT
Code Example
Php :: twig log variable 
Php :: get all users created in a month laravel 
Php :: laravel factory in custom namespace 
Php :: array push in php 
Php :: php function to remove null value from array 
Php :: laravel queue timeout 
Php :: laravel 6 make http request 
Php :: laravel use config 
Php :: Create Mysqli Table Using Php 
Php :: execute function php 
Php :: get return value from another function laravel 
Php :: array marge in php 
Php :: pdo error message 
Php :: laravel access request in provider 
Php :: how-to-generate-an-xlsx-using-php 
Php :: php remove value from array 
Php :: Gravity Form Shortcode Wordpress 
Php :: laravel get route path uri 
Php :: laravel Access to HMLHttpRequest from origin has been blocked by CORS policy: No Access-Control-Allow-Origin 
Php :: how get the size of image in laravel 
Php :: codeigniter sanitize input field 
Php :: laravel url with parameters blade 
Php :: laravel where and where 
Php :: get array of last 3 dates with carbon 
Php :: How to use Query builder with eloquent in Laravel 8? 
Php :: laravel collection to array 
Php :: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes 
Php :: the post function wordpress 
Php :: Invalid credentials. symfony 
Php :: Rename route resource in laravel 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =