codeigniter 我如何获得所选国家代码的值

1szpjjfi  于 2023-01-06  发布在  其他
关注(0)|答案(1)|浏览(116)

我是新的Js和我能够得到的电话号码是通过,但不能得到国家代码,我已经选择了我怎么能得到它在我的控制器

<!DOCTYPE html>
<html lang="en">
 <head>
   
   <meta name="viewport" content="width=device-width, initial-scale=1" />
   <link
     rel="stylesheet"
     href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/css/intlTelInput.css"
   />
   <script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/intlTelInput.min.js"></script>
 </head>
 <body>
   <input id="phone" type="tel" name="phone" />
 </body>
  <script>
   const phoneInputField = document.querySelector("#phone");
   const phoneInput = window.intlTelInput(phoneInputField, {
     utilsScript:
       "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js",
   });
 </script>
</html>

这是我的test.php视图页面

public function send_mail() {
    
        $this->load->library('form_validation');
        $this->form_validation->set_rules('fname', 'First Name', 'required');
        $this->form_validation->set_rules('lname', 'Last Name', 'required');
        $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
        $this->form_validation->set_rules('phone', 'Phone', 'required|regex_match[/^[0-9]{10}$/]');
        $this->form_validation->set_rules('esubject', 'Subject', 'required');
        $this->form_validation->set_rules('msg', 'Message', 'required');
        // $this->form_validation->set_rules('g-recaptcha-response', 'Capcha', 'required');
    
        if ($this->form_validation->run() == FALSE) {
          $this->load->view('contact');
          }
       else {
    
      $to = "";
        $cc = "";
        $fname = $this->input->post('fname');
        $lname = $this->input->post('lname');
        $email = $this->input->post('email');
        $phone = $this->input->post('phone');
        echo $phone; exit;
}
}

这是我的控制器Main.php
我需要在这个变量$phone中获得国家代码和电话号码;

相关问题