Oct 29, 2017
0
Level 2
How can I loop in jquery validate?
My form use vue.js 2
The vue component like this :
<template>
...
<li v-for="item in items">
<input type="hidden" :name="'photo[' + item + ']'" :id="'photo-' +item">
...
</li>
...
</template>
<script>
export default {
data() {
return {
items: [1,2,3,4,5]
}
}
...
}
</script>
I have 5 box image to upload photo
For example :
If I upload photo on the first box, the name to be : photo[1]
If I upload photo on the second box, the name to be : photo[2]
etc
Here I did not give my photo upload code. I just give the code as necessary. In essence if user upload photo, it will save the file in temp and give value to input text each box
My problem is make dinamyc validate in jquery validate
I have validate.js like this :
...
product: {
rules: {
photo: {
required: true,
}
},
messages: {
photo: 'Minimal 1 photo'
},
errorElement: 'span',
errorPlacement: errorPlacement,
highlight: highlight,
unhighlight: unhighlight
},
...
Seems it will loop in jquery validate. But I'm still confused
Essentially at least 1 input text must have filename value. Otherwise there will be validation
How can I do it?
Please or to participate in this conversation.