javascript - form validation not working, for gettting submitted without being validated -


I can not understand what I'm doing wrong here .... without being presented for verification All forms are still being tried. I do not know that this problem is working on it for the last four hours, every time I click the submit button and submit the successful page directly ... can anyone help me with it?

  & lt; Script type = "text / javascript" & gt; Validate the function () (if (document.orderForm.firstName.value == "") {document.getElementById ('Errors'). InnerHTML = "Please enter a first name"; document.orderForm.fistName.focus () ; return false); } If (document.orderForm.lastName.value == "") {document.getElementById ('Errors'). InnerHTML = "Please enter a last name"; Document.orderForm.lastName.focus (); return false); } If (document.orderForm.address.value == "") {document.getElementById ('Errors'). InnerHTML = "Please enter an address"); Document.orderForm.address.focus (); return false); } If (document.orderForm.city.value == "") {document.getElementById ('Errors'). InnerHTML = "Please enter a city"); Document.orderForm.city.focus (); return false); } If (document.orderForm.postalCode.value == ""; document.orderForm.postalCode.value.length! = 6) {document.getElementById ('Errors'). InnerHTML = "Please enter a correct postal code"); Document.orderForm.postalCode.focus (); return false); } If (document.orderForm.province.value == "select") {document.getElementById ('Errors'). InnerHTML = "Please select your province") Return (false); } If (document.orderForm.widget1qty.value == "0" || document.orderForm.widget1qty.value == "" & amp; document.form.indt 2qty.value == "0" || document OrderForm. Widget2qty.value == "" & amp; amp; document.repair.windet2qty.value == "0" || document.orderForm.widget2qty.value == "") {document.getElementById ('Errors') . InnerHTML = "Please select at least one item") Returns (wrong); } And {return (true); }} & Lt; / Script & gt; & Lt; Form name = "orderForm" method = "POST" verb = "processForm.html" permit = "validate return ();" & Gt;  

Look at this sample code, of course, resolve your problem

  & lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Form validation & lt; / Title & gt; & Lt; Script type = "text / javascript" & gt; & Lt ;! - Validate the function () (if (document.myForm.Name.value == "") {document.getElementById ("Errors"). InnerHTML = "Please enter first name"; Document.myForm.Name.focus () ; The details are false;} return (true);} // -> gt; & lt; / script & gt; & gt; body & gt; & lt; body & gt; & lt; form action = "processForm. Html "name =" myForm "onsubmit =" return (valid); "> gt; table cells =" 2 "cellpadding =" 2 "border =" 1 "> gt; & lt; tr & gt; & Lt; td align = "right"> Name    gt;  & lt; td & gt; & lt; input type = "submit" value = "submission Do "/>     gt; id id =" errors "& gt;    

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -