The Form Verification codes and Form Verification Codes

Source: Internet
Author: User
Tags php form

The Form Verification codes and Form Verification Codes


Verification code is a commonly used function for registration, login, and other forms. to prevent malicious forms from being entered and submitted continuously, this poses a security risk. Generally, the verification code image can be switched randomly. The form can be successfully submitted only after the verification is successful remotely. Implemented the simple verification code Function

<Form>

<Div class = "joinCon"> <div class = "row"> <div class = "label"> <em class = "musTip"> * </em> User Name: </div> <div class = "cell"> <input type = "text" data-checkurl = "/supajaxcheck/checkusername" name = "username" class = "inTxt"> </div> <div class = "row"> <div class = "label"> <em class = "musTip"> * </em> password: </div> <div class = "cell"> <input type = "password" name = "password" class = "inTxt"> </div> <div class = "row"> <div class = "label"> <em class = "musTip"> * </em> confirm the password: </div> <div class = "cell"> <input type = "password" name = "repassword" class = "inTxt"/> </div> <div class = "row verBox"> <div class = "label"> <em class = "musTip"> * </em> Verification Code: </div> <div class = "cell verCode"> <input type = "text" data-checkurl = "/joinin/checkcode" class = "inTxt w115 fl n-invalid" name = "key"> <div class = "checkCode">  <a href =" javascript: return false; "> change one </a> </div>


</Form>


Js code snippet:

var verCode = $('div.verCode','form');        verCode.each(function(){            var box = $(this),                img = $('img.checkPic', box),                src = img.attr('src'),                chg = $('a', box),                ipt = $('input.checkCode', box);            chg.on('click', function(e) {                e.preventDefault();                e.stopPropagation();                var _src = src+'&'+$.now();                img.attr('src', _src);            });            img.on('click', function(e) {                e.preventDefault();                e.stopPropagation();                var _src = src+'&'+$.now();                img.attr('src', _src);            });        });



PHP form verification code

Your verification code is not added for verification. Please give it a try.
 
Add the JS verification code to the webpage form

<Script>
Function chk (){
....
}
</Script>
<Form action = "result. asp" method = "post" onSubmit = "return chk ()">
...
</Form>
The chk () function is a verification function. return true when the submission condition is met; return false when the submission condition is not met

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.