I have a form with this input and buttons:
And I'm using this javascript code to add the number of "inputs" to the "button":
$ (function) {Var c = 0; $ ("# Button1") Click (function () {c = $ ("# inputs"). Val (); $ ("# mydiv") .HTML (""); ('& lt; input type = "Text" id = "name '+ i +'" name = "name '+ i +'" (i = 1; i & lt; = c; i ++) {$ ("# mydiv"). '& Lt; input type = "number" id = "rating" + i + "name =" rating "+ i +' 'min =" 1 "max =" 10 "placeholder =" rating' + i + "& Gt; & lt; br / & gt; ');}}); $ (" # button2 "). Click (function () {if (C === 0) Alert (' 'Continue' 'button ');});});});
I need to try to enter a value in the user's "input" (input type) I'm done and click on the "Continue" button (button 1). This way it is not working (a value should be entered in "input", but click on "button 2" without clicking on "button 1"
$ (function () {var c = 0; $ (" # button1 "). Click (function () {if (! $ ('$ Inputs') [0] .checkValidity () () ($ ('#input') [0] .title); Return return;} c = + $ ("# inputs"). Val (); $ ("# Mydiv"). For Html ("") (i = 1; i & lt; = c; i ++) {$ ("# mydiv"). Attachments ('& lt; Input type = "text" id = "name' + i + '" name = "name' (I + '')" placeholder = "name '+ i +'" "gt; '); $ ("# Mydiv") .andend (''
& lt; Script src = "https://ajax.googleapis.com/ajax/ libs/jQuery/1.1.1/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Input type = "number" id = "input" name = "input" min = "3" max = "48" pattern = ". {1,2}" expected title = "Please enter values between 3 to 48" & Gt; & Lt; Input type = "button" id = "button1" value = "continue" & gt; & Lt; Div id = "mydiv" & gt; & Lt; / Div & gt; & Lt; Input type = "submit" id = "button 2" value = "next" disabled>
Comments
Post a Comment