偶然发现有一堆接口,遂闲来无事写了下实现,简单的HTML和css还有js,输入文本生成验证码,样式如下:

闲话少所,上码。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta contentType="application/x-www-form-urlencoded">
	<title></title>
	<script src="https://code.jquery/jquery-3.1.1.min.js"></script>
</head>
<body>
<button id="test">生成验证码</button>
<input type="text" id="text">
<img id="verify">
<script type="text/javascript">
//参考接口:http://www.webxml/WebServices/ValidateCodeWebService.asmx?op=cnValidateImage
$("#test").click(function(){
	var str = $("#text").val();		//获得输入
	$("#verify").attr("src","http://www.webxml/WebServices/ValidateCodeWebService.asmx/cnValidateImage?byString="+str)
});
</script>
</body>
</html>

调用一个web接口,动态生成验证码的base64,想必是img的src属性可以直接放base64,感兴趣的小伙伴可以参考代码中的接口看看,还有一些其它的接口~

更多推荐

在线生成验证码