Home >Web Front-end >HTML Tutorial >Form validation_html/css_WEB-ITnose

Form validation_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:39:521111browse

script implements username and password verification






Form Verify
                                                                                                                                                                                      Get the content entered by the user
var value = obj.value;
/3.Get span
var span = document.getElementById('s1');
span.innerHTML = "";
if (reg.test(value)) {
   span.innerHTML = 'Username cannot be empty' ;
                                                                                                                                                                                                                                                                                                                                                                                                               var checkPwd                                                                                          Password box
var pwd = document.forms[0]['pwd'];
var reg = /^s*$/;
var span = document.getElementById ('s2');
                                                                                                                                                                                                                                                                                                                     span.className = 'error'; >                                                                      return false;                     span.innerHTML = 'Password length cannot be less than 6 characters';
;
                                                                  return false;                                                                                                                                                                                              🎜>var repwd = document.forms[0]['re1'];
                                                                                                                                                     >           var span = document.getElementById('s3');
                  span.innerHTML = ''; 🎜>                                                                                                                                                                                                                                                                     span.innerHTML = 'Two passwords are inconsistent';
                     span.className = 'error'; span.innerHTML = 'ok';
span.className = 'info';
return true;
                                                                                             ) {
                                                                                                                                        //3. Get span username') {
var span = document.getElementById('s1');
span.innerHTML = 'Username is required';
span.className = 'info';
>                                                                                                                                                                                         The password length cannot be less than 6 characters!';
                                                                           className = 'info';
                                                                                                            Provide id value for input document.getElmentById();
//2. Get tbody,tbody.getElementsByTagName('input');
//Document.forms can get all form objects in the document
/ /documeents.Forms [0] [name | ID]
var nameinput = document.forms [0] ['username'];
console.log (nameinput);                return checkName(nameInput) && checkPwd() && checkRepwd();
            }
        
        
    

    
        

用户注册


        

            

                
                    
                    
                    

                
                
                    
                    
                    
                
                
                    
                    
                    

                
                
                    

                
            
用户名
                        
                    

                        
                    
密码
                        
                    

                        
                    
重复密码
                        
                    

                        
                    

                        
                        
                    

        

    

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn