coreui-free-vue-admin-template icon indicating copy to clipboard operation
coreui-free-vue-admin-template copied to clipboard

$refs not access CFormInput Component

Open viral-prm opened this issue 11 months ago • 1 comments

Here is my form component and I'm applying custom validation to validate valid phone number format

<CFormInput type="text" class="form-control" v-model="customer.ContactPhone" ref="contactPhonea" feedbackInvalid="Please provide valid contact phone." @input="validatorContactPhone" required />

here is script

<script>
  export default {
    name: 'Customer',
  data() {
    return {
      customer: {
        ContactPhone:""
      }
    }
  },
  methods: {
    validatorContactPhone() { 
      
      let val = this.$refs.contactPhonea.value;
      if(!this.validPhone(val)){                
        this.$refs.contactPhonea.setCustomValidity("**some notification string ...**")        
      }
      else{
        this.$refs.contactPhonea.setCustomValidity('');
      }
      return val ? this.validPhone(val) : true
    },
  }
</script>

as in above method could not getting this.$refs.contactPhonea.value value of input

Looking for Help Thanks in advance..

viral-prm avatar Mar 22 '24 09:03 viral-prm

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar May 22 '24 02:05 github-actions[bot]