ASP is the simplest code for generating verification codes.

Source: Internet
Author: User

To prevent further attacks, perform a verification code filter. Program It is necessary. I found some information on the Internet and thought it was done by others. Code It's always uncomfortable. You don't need to write complicated code, especially for generating images. I tried many methods on the Internet, but I don't know why. Maybe I have no experience. It seems complicated.
It took an hour to write a super simple verification code. Haha is absolutely original and there are only a dozen lines of code. It is generated randomly. Because it is relatively simple, it cannot deal with those powerful posting software, but it is always better than not. After I put the verification code, I observed that I didn't see any spam posts for a few days, it should be effective, haha.
Example:
====== Show. asp ====== Copy code The Code is as follows: <%
Randomize
Randm = int (9000 * RND) + 1000) randomly generates 4-digit code
%>

Verification Code: <input name = YZM id = netadd size = 4 maxlength = "4"> <% = randm %> This is a text box, And the randomly generated function is called next to it.

This js code is used to verify whether the entered verification code is correct.Copy codeThe Code is as follows: <SCRIPT type = text/JavaScript>
Function sendform (OBJ)
{
If (obj. YZM. value! = "<% = Randm %> ")
{
Alert ("Incorrect verification code ");
OBJ. content. Focus ();
Return false;
}
OBJ. Submit ();
Return true;
}
</SCRIPT>

Add this sentence to the OK button.
<Input onclick = sendform (this. form); type = button name = "submit2" value = "add">
The red text must be clear. If it does not match, it cannot run.
Basically, it is so simple. It can be said that it is the core code. In fact, it can be more complicated, but it has not yet been intended to be done. When will it be followed by junk posts.

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.