Attract Men or Women

Form to Json how to exclude disabled elements from the output

I am trying to exclude the disabled elements from the Json output. Can anyone help me.
Below is the code i am using. I have made the part in question bold.

My apologies if this seems like a retarded question.

/\**
\ Start Form to Json*
\/*
let isValidElement = element => {
return element.name && element.value;
};
let isEnabledElement = element => {
return (!(element.prop('disabled')));
};
let isValidValue = element => {
return (!['checkbox', 'radio'].includes(element.type) || element.checked)
};
let formToJson = elements => [].reduce.call(elements, (data, element) => {
if (isValidElement && isValidValue && isEnabledElement){
data[element.name] = element.value;
}
return data;
}, {});
let handleFormSubmit = event => {
event.preventDefault();
//call our function to get the form data
let data = formToJson(form.elements);
let dataString = document.getElementsByClassName('jsonObject')[0];
dataString.textContent = JSON.stringify(data, null, " ");
};
let form = document.getElementsByClassName('form_nostium')[0];
if (form){
form.addEventListener('submit', handleFormSubmit);
}

/\**
\ End Form to Json*
\/*

submitted by /u/Friggidy_Foogshmaer
[link] [comments][Collection]webdev
Form to Json how to exclude disabled elements from the output Form to Json how to exclude disabled elements from the output Reviewed by Duos on October 25, 2019 Rating: 5

No comments:

Law Of Attraction : Quantum Manifest

Powered by Blogger.