Form validation in javascript - minimum characters -
I need to validate a form and I want every input to be more than 6 characters.
The following script is working for 0 characters
How do I edit it to set the minimum letters to 6?
& lt; Script & gt; Validate function form (form id) {var input, index; Var form = document.getElementById (formId); Input = form.gate elements biatagnam ('input'); ({Index [index] .value == ft; input [index] .value = (if index [index] is to deal with {index] [index] element for index (index = 0; index & lt; inputs.length; ++ index) = "") {Warning ("field is empty"); return false; }}}
Here's the form:
& lt; Form name = "myForm" id = "myForm" method = "post" action = "onsubmit =" validate return form ('miform'); " Style = "margin-bottom: 10px;" _lpchecked = "1" & gt; & Lt; Div id = "InputsWrapper" & gt; & Lt; Div & gt; & Lt; Input type = "text" name = "mytext []" id = "field_1" value = "http: //" & gt; & Lt; A href = "#" id = "AddMoreFileBox" style = "font-size: 12px; margin: 0x0x 0;" & Gt; & Lt; Img src = "picture / plus page" style = "margin-left: 10px; height: 24px;" & gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div style = "height: 10px;" & Gt; & Lt; / Div & gt; & Lt; Input type = "submit" style = "border: none; background color: # ff 9900; padding: 10px 30px 10px 30px; font-size: 24px; font-weight: bold; color: #FFF;" Value = "continue" & gt; & Lt; / Form & gt;
inside the loop, check value
length {/ Code>
if (input [index] .value == ft. Input [index] .value == "" || input [index] .value.length & lt; 6) {Warning ("Field 6 characters are not minimum!"); return false; }
Comments
Post a Comment