I need to use the verification code. I suddenly wondered if I could use Js for the verification code?
Of course, JavaScript cannot be mapped, but it can be simulated as a verification code using Js.
So it took me 20 minutes to try it out based on my ideas, and it was better than I thought.
First paste a picture to see
Code:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head >
< Title > No title page </ Title >
< Style Type = "Text/CSS" >
. Code
{
Background-Image : Url(code.jpg) ;
Font-family : Arial ;
Font-style : Italic ;
Color : Red ;
Border : 0 ;
Padding : 2px 3px ;
Letter-spacing : 3px ;
Font-weight : Bolder ;
}
. Unchanged
{
Border : 0 ;
}
</ Style >
< Script Language = "JavaScript" Type = "Text/JavaScript" >
VaR Code; // Define the verification code globally
Function Createcode ()
{
Code = "" ;
VaR Codelength = 6 ; // Verification code length
VaR Checkcode = Document. getelementbyid ( " Checkcode " );
VaR Selectchar = New Array ( 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 'A', 'B', 'C', 'D', 'E', 'E', 'F', 'G', 'h', 'I ', 'J', 'k', 'l', 'M', 'n', 'O', 'P', 'Q', 'R','s ', 'T', 'U', 'V', 'w', 'x', 'y', 'z '); // All characters that can be used to form verification codes.
For ( VaR I = 0 ; I < Codelength; I ++ )
{
VaR Charindex = Math. Floor (math. Random () * 36 );
Code + = Selectchar [charindex];
}
// Alert (Code );
If (Checkcode)
{
Checkcode. classname = " Code " ;
Checkcode. Value = Code;
}
}
Function Validate ()
{
VaR Inputcode = Document. getelementbyid ( " Input1 " ). Value;
If (Inputcode. Length <= 0 )
{
Alert ( " Enter the verification code! " );
}
Else If (Inputcode ! = Code)
{
Alert ( " Incorrect verification code! " );
Createcode (); // Refresh Verification Code
}
Else
{
Alert ( " ^-^ OK " );
}
}
</ Script >
</ Head >
< Body >
< Form Action = "#" >
& Nbsp; < Input Type = "Text" Onclick = "Createcode ()" ID = "Input1" />
< Input Type = "Text" ID = "Checkcode" Class = "Unchanged" Style = "Width: 80px" /> < BR />
< Input ID = "Button1" Onclick = "Validate ();" Type = "Button" Value = "OK" /> & Nbsp;
</ Form >
</ Body >
</ Html >
Well, after reading the story, I hope you don't have to laugh at it. I just played it for the sake of practice (
not to mention the explanation, the comment should be clear.
In fact, the background image used to confuse text only adds a background image below the text. The verification code still cannot prevent copy, therefore, it cannot be used as a real verification code.
here, I have designed some things in JS & CSS recently, such as Haha, practice, learning, and progress ~