javascript - Trying to get form validation working with jQueryUI image array -
I am only trying to allow the user to submit the form when verification has been returned and they The correct order is drawn in the pictures At the present time, I have the form input elements, but it seems that the user can create a bug, where the user can still submit the form even if the image is in the wrong order. I have two submitted buttons that again order all the images in the array and the one that I want to validate if all the data is correct. I currently have the onclick button on the onclick = "return valid ();
.on
submit button. I'm not sure what I'm doing wrong. It is possible that I am new to JavaScript and jQuery.
HTML:
form action = "https: // Stackoverflow.com" method = "POST "OnSubmit =" class = "a" & gt; name: & lt; input type = "text" class = "text" name = "name" id = "name" />
; Address: & lt; input type = "text" class = "text" name = "address" id = "address" />
Email: & lt; input type = "text" Class = "text" name = "email" id = "email" /> gt;
& gt; & lt; / li & gt; ; & Lt; li id = "2" class = "ui-state-default" & gt; & lt; img src = "2.png" width = "100" height = "90" /> & Lt; / Li & gt; & Lt; Li id = "3" square = "ui-state-default" & gt; & Lt; Img src = "3.png" width = "100" height = "90" /> & Lt; / Li & gt; & Lt; Li id = "4" class = "ui-state-default" & gt; & Lt; Img src = "4.png" width = "100" height = "90" /> & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; Div style = "clear: both;" & Gt; & Lt; / Div & gt; & Lt; Input name = "submit" value = "re-order" type = "submit" /> & Lt; Input type = "button" id = "submit" value = "submit" name = "submit" onclick = "valid valid ();" / & Gt; & Lt; / Form & gt; Javascript:
$ (window) .load (function () {$ (function () {$ ("# sortable"). {Placeholder : "Ui-state-highlight", cursor: 'crosshair', update: function (Event, UI) {var order = $ ("# Sortable"). Sortable ("toure"); Order = JSON. Stringify (order); console.log; correct = JSON.stringify (["4", "3", "2", "1"]); if (order == true) {valid = true;} }} $ ("Form Input") $ ("# sortable"). DisableSelection (); $ ('click', function) {var valid = true, message = ''; $. (Function () {var $ this = $ (this); if (! $ This.val ()) {var inputName = $ this.a Ttr ('name'); valid = false; message + = 'please enter your' + InputName + '\ n';}}); if (! Valid) {warning (message); console.log ("not valid ");} And {//window.location.href =" http: //stackoverflow.com "; console.log (" valid ");} description is false;});});}); on input tag Change the value of the type.
Change the type of value on the input tag.
& lt; Input type = "submit" id = "submit" value = "submit" name = "submit" onsubmit = "valid value ();" / & Gt;
Comments
Post a Comment