Tuesday, 15 September 2015

javascript - How to detect whether an html input object is a button or not? -


I am trying to pull input from a form, except the button, but not the radio button. I have my input form of element. () Method I am getting through. I have input, but I am unable to restrict them to input other than the submit button or similar button. I have tried jquery .is (), .type (), any suggestions / references with no luck will not be useful because I have not found anything yet. Here I am using the code to draw the form.

  var inputs = formList.find (": input"); If (inputs? Inputs.length & gt; 0: false) {for (j = 0; j & lt; inputs.length; j ++) {console.log ("input:" + inputs [j]); If (input [j] .name! = "") {WebForms.push ({"inputName": input [j] .name}); } And if (inputs [j] .id! = "") {WebForms.push ({"Input" name ": Input [J] .ID});}}}  

Like I said, I have tried. And there is no luck with no type. Here is an example of how I was using .is ()

  var formList = $ ("form "FORM" ("form"); attr ("name"); if (formList! = Null? FormList.length & gt; 0: false) {if (formList.length & lt; 2) {if (FormList.attr ("name")? FormList.attr ("name")! = "": False) {// warning ("the name of the form is not empty"); // warning ("name of the form:" + Formaldehyde (" Name ")); var webform = []; // warning (" formlite name: "+ formlive [i]); var input = formList.find (": input "); if (inputs? Inputs.length & gt; 0: false) {for (j = 0; j & lt; inputs.length; j ++) {console.log ("input:" + inputs [j]); if (input [j] .name! = " ") {If ([[]] ({[input.js] .is (": button ")) {console.log (input [j] .name +" is a button ");} WebForms.push ({" inputName ": input [ja] ] .name}};} and if (input [ja]. Id! = "") {If (input [j] .is (": button")) {console.log (input [j] .name + " Have a button "); } WebForms.push ({"inputName": Input [J] .id}); }} //alert(JSON.stringify(webForms)); JsonForm.forms [jsonForm.forms.length - 1] .name = formList.attr ("name"); // Alert ("Jason Form's Name:" + JSON.stringify (jsonForm)); JsonForm.forms [jsonForm.forms.length - 1] .inputs = webForms; // Alert ("Name:" + jsonForm.forms [jsonForm.forms.length - 1] .name); }}  

Any help here is appreciated.

You can use the following code to get these input elements: the button Not s or input s with a "submit" feature with a type .

  var inputs = formList.find (': input: no (button, [type = "submit"]));  

There is a live demonstration.


No comments:

Post a Comment