[input] Verify that the input data is legal
jingyuexing opened this issue · comments
Data validation based on component type
<input type="email"> // Check if it is a valid email string
<input type="color"> // Check if it is a valid color string. and so on
- phoneNumber (EN,USA,CN,FR,IN...etc)
- ascii
- number
- max number
- min number
- max length
- min length
- uuid
- custome regexp
and others not listed, like data, time,
Hi @jingyuexing
If you add a type
attribute then it will get validated via HTML form. However, if you want to validate using JS, here's an example of how to do it: https://anu-vue.netlify.app/guide/components/input.html#validation
I guess this is what you are looking for. If not, can you please provide more information like how you want to validate it?
Hi @jingyuexing
If you add a
type
attribute then it will get validated via HTML form. However, if you want to validate using JS, here's an example of how to do it: https://anu-vue.netlify.app/guide/components/input.html#validationI guess this is what you are looking for. If not, can you please provide more information like how you want to validate it?
<input type="email" id="email"/>
let validators={
password(val):{
// TODO
},
phone(val){
// TODO
},
uuid(val){
}
}
let ele = document.getElementById("password")
let inputType = ele.getAttribute("type")
validator[inputType](ele.value)
I want it to be fully automatic, not manual
Hi @jingyuexing
If you add a
type
attribute then it will get validated via HTML form. However, if you want to validate using JS, here's an example of how to do it: https://anu-vue.netlify.app/guide/components/input.html#validationI guess this is what you are looking for. If not, can you please provide more information like how you want to validate it?
I want it to be fully automatic, not manual,