I'm trying to get the value of a field configured with the plugin intl-tel-input , in which I ask the user to enter their phone number. The problem is that, for some reason, when sending the data to the server, the field (named phone
) is empty:
comments: "Comentario"
contact: "Correo"
email:"[email protected]"
name: "Xab"
phone: ""
read: true
surname: "Montoto"
zip: 1111
The input
is this:
<div><input type="text" class="form-control form-control-200" name="phone" ng-model="vm.form.phonepasar" id="phone_pasar" ng-maxlength=15 maxlength=15 ng-model-options="{ updateOn: 'blur' }"/>
The options I have tried to overcome the error are:
Create a hidden field and copy the value of the data. This, effectively, allows to pass the value to the server. However, by requiring the required
parameter, I can not put it in type=hidden
, nor display:none
, nor visibility:hidden
, since apparently it is necessary for the user to manually modify this field to be considered valid.
Use the JSValidate plugin to ignore the required
parameter. Neither has worked.
What must be done so that when you call the function save()
you can pass the value of the telephone field to the server?:
function save() {
vm.isSaving = true;
var valorOculto = $("#phone").intlTelInput("getNumber", intlTelInputUtils.numberFormat.E164);
$("#phone").val(valorOculto);
ContactaServiceRest.contacto(vm.form, onSaveSuccess, onSaveError);
}