用html苹果登录注册账号

用html苹果登录注册账号,第1张

用html苹果登录注册账号方法如下:

1、点击进入苹果官方网站。

2、在苹果官网首页点击最右侧的购物袋。

3、在d出的下拉菜单中点击最下面的登录按键。

4、在d出的对话框中点击右侧的没有AppleID,新建账号。

5、d出的新页面中按照提示输入相应的资料,在输入密码时要注意:①至少8个字符。②大写与小写都有。③至少一个数字。输入完之后点击最下面继续。

6、接着电脑d出一个邮件验证的六位验证码,此时打开你注册时使用的邮箱登录查看你的验证码,输入进去。

7、之后账号就建立成功了,你就可以使用这个账号登录Apple账号了。

下面是关键代码,如果剩下的你都搞不懂,我就无语了

JS

<script type="text/javascript" language="javascript">

function reloadcodeOne(){//刷新验证码函数

var verify = document.getElementById('checkCodeImg')

verify.setAttribute('src', 'validateCode?dt=' + Math.random())

}

<script type="text/javascript" >

html

<p>

<label>验证码:</label>

<input class="code" value="请输入验证码" title="请输入验证码" name="rendCode" id="rendCode" onfocus="if (value =='请输入验证码'){value =''}" onblur="if (value ==''){value='请输入验证码'}" type="text" size="6" />

<span><img id="checkCodeImg" src="validateCodeServlet" onclick="javascript:reloadcodeOne()" alt="" width="75" height="24" /></span>

</p>

java代码

package com.zhihui.action.common

import java.awt.Color

import java.awt.Font

import java.awt.Graphics2D

import java.awt.image.BufferedImage

import java.util.Random

import javax.imageio.ImageIO

import javax.servlet.ServletException

import javax.servlet.ServletOutputStream

import javax.servlet.http.HttpServletRequest

import javax.servlet.http.HttpServletResponse

import javax.servlet.http.HttpSession

import org.apache.struts2.ServletActionContext

import com.zhihui.action.base.BaseAction

/**

* <p>

* 校验码控制器

* </p>

*

* @author liurong

* @version ValidateCodeServlet.java,v 0.1 2008-11-20 上午09:22:31 Administrator

* Exp

*/

public class ValidateCodeAction extends BaseAction {

private static final long serialVersionUID = 1L

// 验证码图片的宽度。

private int width = 10

// 验证码图片的高度。

private int height = 5

// 验证码字符个数

private int codeCount = 5

private int x = 0

// 字体高度

private int fontHeight

private int codeY

/*char[] codeSequence = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J',

'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'W',

'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7', '8', '9' }*/

char[] codeSequence = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0' }

HttpServletRequest req=ServletActionContext.getRequest()

HttpServletResponse resp=ServletActionContext.getResponse()

public String execute()

throws ServletException, java.io.IOException {

// 宽度

String strWidth = "70"

// 高度

String strHeight = "22"

// 字符个数

String strCodeCount = "5"

width = Integer.parseInt(strWidth)

height = Integer.parseInt(strHeight)

codeCount = Integer.parseInt(strCodeCount)

x = width / (codeCount)

fontHeight = height - 4

codeY = height - 4

// 定义图像buffer

BufferedImage buffImg = new BufferedImage(width, height,

BufferedImage.TYPE_INT_RGB)

Graphics2D g = buffImg.createGraphics()

Random random = new Random()

// 将图像填充为白色

g.setColor(Color.WHITE)

g.fillRect(0, 0, width, height)

Font font = new Font("Fixedsys", Font.PLAIN, fontHeight)

g.setFont(font)

g.setColor(Color.BLACK)

g.drawRect(0, 0, width - 1, height - 1)

g.setColor(Color.BLACK)

for (int i = 0i <15i++) {

int x = random.nextInt(width)

int y = random.nextInt(height)

int xl = random.nextInt(8)

int yl = random.nextInt(8)

g.drawLine(x, y, x + xl, y + yl)

}

// randomCode用于保存随机产生的验证码,以便用户登录后进行验证。

StringBuffer randomCode = new StringBuffer()

int red = 0, green = 0, blue = 0

for (int i = 0i <codeCounti++) {

String strRand = String.valueOf(codeSequence[random.nextInt(codeSequence.length)])

red = 0//random.nextInt(255)

green = 0//random.nextInt(255)

blue = 0//random.nextInt(255)

g.setColor(new Color(red, green, blue))

g.drawString(strRand, (i ) * x, codeY)

randomCode.append(strRand)

}

HttpSession session = req.getSession()

session.setAttribute("validateCode", randomCode.toString())

resp.setHeader("Pragma", "no-cache")

resp.setHeader("Cache-Control", "no-cache")

resp.setDateHeader("Expires", 0)

resp.setContentType("image/jpeg")

ServletOutputStream sos = resp.getOutputStream()

ImageIO.write(buffImg, "jpeg", sos)

sos.close()

return null

}

public int getWidth() {

return width

}

public void setWidth(int width) {

this.width = width

}

public int getHeight() {

return height

}

public void setHeight(int height) {

this.height = height

}

public int getCodeCount() {

return codeCount

}

public void setCodeCount(int codeCount) {

this.codeCount = codeCount

}

public int getX() {

return x

}

public void setX(int x) {

this.x = x

}

public int getFontHeight() {

return fontHeight

}

public void setFontHeight(int fontHeight) {

this.fontHeight = fontHeight

}

public int getCodeY() {

return codeY

}

public void setCodeY(int codeY) {

this.codeY = codeY

}

public char[] getCodeSequence() {

return codeSequence

}

public void setCodeSequence(char[] codeSequence) {

this.codeSequence = codeSequence

}

public HttpServletRequest getReq() {

return req

}

public void setReq(HttpServletRequest req) {

this.req = req

}

public HttpServletResponse getResp() {

return resp

}

public void setResp(HttpServletResponse resp) {

this.resp = resp

}

}

可以用JS做个简单的验证码 <script language="javascript">var code//在全局 定义验证码

function createCode()

{ //创建验证码函数

code = ""

var codeLength =5//验证码的长度

var selectChar = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z')//所有候选组成验证码的字符,当然也可以用中文的

for(var i=0i<codeLengthi++)

{

var charIndex =Math.floor(Math.random()*36)

code +=selectChar[charIndex]

}// 设置验证码的显示样式,并显示

document.getElementById("discode").style.fontFamily="Fixedsys" //设置字体

document.getElementById("discode").style.letterSpacing="3px" //字体间距

document.getElementById("discode").style.color="#ff0000" //字体颜色

document.getElementById("discode").innerHTML=code // 显示

}</script>把上面一段JS代码放到<head></head>标签中在页面装载的时候,调用验证码创建函数 <body onload="createCode()

">在验证码输入框的后面放一个标签 <span id="discode"></span>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7515671.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-06
下一篇 2023-04-06

发表评论

登录后才能评论

评论列表(0条)

保存