Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$refs not access CFormInput Component #303

Open
viral-prm opened this issue Mar 22, 2024 · 1 comment
Open

$refs not access CFormInput Component #303

viral-prm opened this issue Mar 22, 2024 · 1 comment

Comments

@viral-prm
Copy link

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..

Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant