I have a vuejs form component that has about 5 input fields for example.
But I need to separate the form component into 2 forms that take different user input.
Form 1 has
Name
Surname
Email
with a form name attribute value or form_1
Form 2 has
Username
Password
with a form name attribute value or form_2
The code:
created: function (formNameAttribute, inputNameAttribute) {
var getForms = document.getElementsByTagName('form');
var inputElement = document.querySelectorAll('input');
for (var i = 0; i < getForms.length; i++) {
formNameAttribute = getForms[i].name;
switch (getForms[i].name) {
case 'Account Details':
console.log('Form Name: ', getForms[i].name);
break;
case 'Account Login':
console.log('Form Name: ', getForms[i].name);
break;
default:
}
for (var j = i; j < inputElement.length; j++) {
inputNameAttribute = inputElement[j].name;
console.log('Input name attribute: ', inputNameAttribute);
}
}
}
How can I tell the form component to only display the fields it needs for form_1 and form_2
external link to code: Form Component