国际电话输入隐藏值未通过表单提交

时间:2019-01-11 09:57:50

标签: javascript html intl-tel-input

我已经这样实现intl-tel-input

    var ppvar;

    function primaryPhoneDisplay(assignedName){
      let countryPhoneNumer = document.querySelector(`input[name="${assignedName}"]`);
      ppvar = window.intlTelInput(countryPhoneNumer, {
          separateDialCode: true,
          initialCountry: "IN",
          preferredCountries: ["IN"],
          nationalMode: false,
          hiddenInput: "primary_phone_test",
          formatOnDisplay: false,
          utilsScript:'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/14.0.6/js/utils.js'
      });
    }

    primaryPhoneDisplay("primaryPhone");

HTML就是这样

<form action="/formsubmit" method="POST" onsubmit="return formSubmit()">

 <input type="text" name="primaryPhone" class="form-control"   oninput="someFunction(this)" placeholder="Phone Number" />

 <input type="submit" value="Submit" />
</form>

inspecting上,隐藏的字段显示在源中,但是在提交表单时,req.body中的字段丢失,除此以外的所有其他字段都在其中。

代码有什么问题吗?

0 个答案:

没有答案