java - How to return an error HTML (Input Validation) -
I am currently developing a web site (part of university assignment)
I have some For example:
var x = document.getElementById ("age") for example: ). Var y = document.getElementById ("Agreement"). Checked; Var z = document.getElementById ("sex") value; If (x! = True & y! = True & amp; z == faucet) {response.sendRedirect ("Register.jsp"); }
I think some kind of error message will appear over the form so that the user can tell that he has created an error within the form. (For example, if they do not enter their gender or do not agree with any of the checkboxes). It has also been mentioned, I would be specific to the error to be a bit more specific to the verification code.
Form:
& lt; H3 & gt; Register as a user & lt; / H3 & gt; & Lt; Form method = "POST" action = "register" & gt; & Lt; Ul & gt; & Lt; Li & gt; First name: & lt; Input type = "text" name = "first name" & gt; & Lt; / Li & gt; & Lt; Li & gt; Last name: & lt; Input type = "text" name = "last name" & gt; & Lt; / Li & gt; & Lt; Li & gt; Email address: & lt; Input type = "email" name = "email" & gt; & Lt; / Li & gt; & Lt; Li & gt; Gender: Male & lt; Input type = "radio" name = "gender" value = "male" & gt; Women & lt; Input type = "radio" name = "gender" value = "woman" & gt; & Lt; / Li & gt; & Lt; Li & gt; Username & lt; Input type = "text" name = "user name" & gt; & Lt; / Li & gt; & Lt; Li & gt; Password & lt; Input type = "password" name = "password" & gt; & Lt; / Li & gt; & Lt; Li & gt; You must be 12 or more to register on this web site. Please check if you are more than 12: & lt; Input type = "checkbox" name = "age" & gt; & Lt; / Li & gt; & Lt; Li & gt; Please check this box to agree to the terms and conditions & lt; Input type = "checkbox" name = "contract" & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; Br / & gt; & Lt; Input type = "submit" value = "register" & gt; & Lt; / Form & gt;
Thank you for any help or advice you can give me, I really appreciate it because I am new to web development and I want to develop the technology that the web developer Use.
var valid = function (form) {var errors = []; If (! Form.sex [0]. Check & amp;! Form.sex [1] checked) {errors.push ('Please choose gender'); } If (! Form.agreement.checked) {errors.push (Please agree with &;;;); } If (errors.length) {warnings (errors.join ('\ n')); return false; } Back true; };
& lt; H3 & gt; Register as a user & lt; / H3 & gt; & Lt; Form method = "POST" action = "Register.jsp" onsubmit = "return valid (this);" & Gt; & Lt; Ul & gt; & Lt; Li & gt; First name: & lt; Input type = "text" name = "first name" & gt; & Lt; / Li & gt; & Lt; Li & gt; Last name: & lt; Input type = "article" name = "last name" & gt; & Lt; / Li & gt; & Lt; Li & gt; Email address: & lt; Input type = "email" name = "email" & gt; & Lt; / Li & gt; & Lt; Li & gt; Gender: Male & lt; Input type = "radio" name = "gender" value = "male" & gt; Women & lt; Input type = "radio" name = "gender" value = "woman" & gt; & Lt; / Li & gt; & Lt; Li & gt; Username & lt; Input type = "text" name = "username" & gt; & Lt; / Li & gt; & Lt; Li & gt; Password & lt; Input type = "password" name = "password" & gt; & Lt; / Li & gt; & Lt; Li & gt; You must be 12 or more to register on this web site. Please check if you are more than 12: & lt; Input type = "checkbox" name = "age" & gt; & Lt; / Li & gt; & Lt; Li & gt; Please check this box to agree to the terms and conditions & lt; Input type = "checkbox" name = "contract" & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; Br / & gt; & Lt; Input type = "submit" value = "register" & gt; & Lt; / Form & gt;
Comments
Post a Comment