10 examples of 'get form data jquery' in JavaScript

Every line of 'get form data jquery' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
80function get(data){
81 // If Pending Uploads
82 if($('input#submit').attr('disabled') == 'disabled'){
83 return false;
84 }
85
86 // Compute & Get JSON
87 SirTrevor.onBeforeSubmit()
88 return SirTrevor.instances[0].$el.val();
89}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

158function getData() {
159 var data = {};
160 var formData = $("form").serializeArray();
161 $.each(formData, function (i, field) {
162 if (field.name === "email") { data.email = field.value.trim(); }
163 if (field.name === "git_url") { data.gitUrl = field.value.trim(); }
164 if (field.name === "doc_theme") { data.docTheme = field.value.trim(); }
165 if (field.name === "debug" ) { data.debug = field.value; }
166 if (field.name === "heroku_api_key" ) { data.herokuAPIKey = field.value.trim(); }
167 if (field.name === "heroku_app_name" ) { data.herokuAppName = field.value.trim(); }
168 if (field.name === "subproject_url[]") {
169 if (data.subProject === undefined) {
170 data.subProject = [field.value];
171 } else {
172 data.subProject.push(field.value);
173 }
174 }
175 if (field.name === "target_branch") { data.targetBranch = field.value.trim(); }
176 if (field.name === "doc_path") { data.docPath = field.value.trim(); }
177 });
178
179 return data;
180}
89function getData($elem){
90 return {
91 title : $elem.find('input[name="title"]').val(),
92 url : $elem.find('input[name="url"]').val(),
93 github_username : $elem.find('input[name="github_username"]').val(),
94 discription : $elem.find('textarea[name="discription"]').val()
95 };
96}
175function get_form_data(form_id, mode) {
176 // Access the form data.
177 var fields = $("form#" + form_id + " :input").serializeArray();
178 //console.log("gfd: %o", fields);
179 // 'fields' is now an array of {"name": foo, "value" : bar} items.
180 // Convert this into a simpler form, create a new dict.
181 var output = {};
182 // Set the mode, which is not provided by the form.
183 output.mode = mode;
184 // Add the rest of the form elements.
185 $.each(fields, function(i, field){
186 output[field.name] = field.value;
187 });
188 return JSON.stringify(output);
189}
534function getFormData(formElem) {
535 var formData = $(formElem).serializeArray(),
536 fileInputs = $(formElem).find("input[type=file]"),
537 files = [];
538
539 fileInputs.each(function () {
540 var fileSize, fileType, fieldName = this.name;
541
542 if (this.files.length > 0) {
543 fileSize = this.files[0].size;
544 fileType = this.files[0].type;
545 } else {
546 fileSize = 0;
547 fileType = '';
548 }
549 files.push({name: fieldName, value: fileSize, fileType: fileType, files: this.files});
550 });
551
552 _.each(files, function (fileObj) {
553 formData.push(fileObj);
554 });
555
556 return formData;
557}
27function getFormData(form) {
28 var formArray = form.serializeArray(),
29 modelMap = {
30 'Mediafile[alt]': 'alt',
31 'Mediafile[description]': 'description',
32 url: 'url',
33 id: 'id'
34 },
35 data = [];
36
37 for (var i=0; formArray.length > i; i++) {
38 if (modelMap[formArray[i].name]) {
39 data[modelMap[formArray[i].name]] = formArray[i].value;
40 }
41 }
42
43 return data;
44}
85function getFormData(form, options) {
86 if (!form) {
87 throw new Error('A form is required by getFormData, was given form=' + form)
88 }
89
90 if (!options) {
91 options = {trim: false}
92 }
93
94 var data = {}
95 var elementName
96 var elementNames = []
97 var elementNameLookup = {}
98
99 // Get unique submittable element names for the form
100 for (var i = 0, l = form.elements.length; i < l; i++) {
101 var element = form.elements[i]
102 if (IGNORED_INPUT_TYPES[element.type] || element.disabled) {
103 continue
104 }
105 elementName = element.name || element.id
106 if (elementName && !elementNameLookup[elementName]) {
107 elementNames.push(elementName)
108 elementNameLookup[elementName] = true
109 }
110 }
111
112 // Extract element data name-by-name for consistent handling of special cases
113 // around elements which contain multiple inputs.
114 for (i = 0, l = elementNames.length; i < l; i++) {
115 elementName = elementNames[i]
116 var value = getNamedFormElementData(form, elementName, options)
117 if (value != null) {
118 data[elementName] = value
119 }
120 }
121
122 return data
123}
1325function getFormData(theForm) {
1326 return $(theForm).serializeObject();
1327}
804function postData() {
805 $("#comment-container").load("/comments",{
806 "parentComment.id" : $("[name='parentComment.id']").val(),
807 "blog.id" : $("[name='blog.id']").val(),
808 "nickname": $("[name='nickname']").val(),
809 "email" : $("[name='email']").val(),
810 "content" : $("[name='content']").val()
811 },function (responseTxt, statusTxt, xhr) {
812 clearContent();
813 });
814}
27function getValue ( name ) {
28 return $('[name="' + name + '"]').val ();
29}

Related snippets