添加页面
Posted wangyang11
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了添加页面相关的知识,希望对你有一定的参考价值。
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Add</title>
<script src="~/Content/jquery-3.1.1.js"></script>
@*验证码类*@
<script src="~/Content/yzmJS.js"></script>
@*验证码样式*@
<link href="~/Content/yzmStyle.css" rel="stylesheet" />
@*布局样式*@
<style>
* {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
}
.login {
margin-left: 450px;
margin-top: 170px;
}
ul {
list-style: none;
}
li {
margin-bottom: 10px;
}
li .bt {
color: red;
}
li .zi {
color: #666;
}
.txtAdd {
width: 285px;
height: 35px;
border: 1px solid aquamarine;
}
.ty {
font-size: 12px;
margin-top: 20px;
margin-left: 90px;
}
.btnAdd {
width: 285px;
height: 35px;
background-color: red;
border: 1px solid red;
color: white;
margin-top: 10px;
margin-left: 90px;
}
.txtAddYZ {
width: 150px;
height: 35px;
border: 1px solid aquamarine;
}
.tp {
width: 80px;
height: 35px;
}
.yz {
font-size: 12px;
}
#spName {
color:red;
font-size:12px;
}
#spPwd0 {
color: red;
font-size: 12px;
}
#ckTong {
color: red;
font-size: 12px;
}
#spYan {
color: red;
font-size: 12px;
margin-left:8px;
}
</style>
</head>
<body>
<form id="FormAdd">
<div class="login">
<ul>
<li>
<span class="bt">*</span>
<samp class="zi"> 用户名</samp>:
<input class="txtAdd" id="Text1" type="text" name="UserName" />
<span id="spName"></span>
</li>
<li>
<span class="bt">*</span>
<samp class="zi"> 请设置密码</samp>:
<input class="txtAdd" type="password" name="UserPassword" />
<span id="spPwd"></span>
</li>
<li>
<span class="bt">*</span>
<samp class="zi"> 请确认密码</samp>:
<input class="txtAdd" type="password" name="pwd0" />
<span id="spPwd0"></span>
</li>
<li>
<span class="bt">*</span>
<samp class="zi"> 验证码</samp>:
<input class="txtAddYZ" type="text" id="yanz" />
<input type="button" id="code" onclick="createCode()" class="tp" />
<a href="javascript:void(0)" onclick="createCode()" class="yz">看不清,再换一张</a><span id="spYan"></span>
</li>
<li class="ty">
<input id="Checkbox1" type="checkbox" name="ck" />
我已阅读并同意<a href="#">《金象网用户注册协议》</a>
<span id="ckTong"></span>
</li>
</ul>
<input id="Button1" class="btnAdd" type="button" value="立即注册" onclick="Add()"/>
</div>
</form>
</body>
</html>
<script>
$(function () {
//获取焦点
$("input").focus();
//用户名文本框失去焦点
$("[name=UserName]").blur(function () {
$.ajax({
url: "/Login/GetUser?Name=" + $("[name=UserName]").val(),
type: "post",
success: function (d) {
console.log(d)
if (d ==1) {
$("#spName").html("用户名以存在")
}
else {
$("#spName").html("")
}
}
})
})
//确认密码框失去焦点
$("[name=pwd0]").blur(function () {
if ($("[name=pwd0]").val() != $("[name=UserPassword]").val()) {
$("#spPwd0").html("两次密码输入不一致");
}
else {
$("#spPwd0").html("")
}
})
})
//验证码,协议验证 加上添加
function Add() {
var oValue = $("#yanz").val().toUpperCase();
console.log(oValue);
if (oValue == 0) {
$("#spYan").html("请输入验证码")
}
else if (oValue != code) {
$("#spYan").html("验证码不正确")
}
else {
$("#spYan").html("")
}
if (!$("#Checkbox1").prop("checked")) {
$("#ckTong").html("尚未同意协议")
return
}
else {
$.ajax({
url: "/Login/Add",
type: "post",
data: $("#FormAdd").serialize(),
success: function (data) {
if (data > 0) {
alert("注册成功")
location.href="/Login/Login"
}
}
})
}
}
</script>
以上是关于添加页面的主要内容,如果未能解决你的问题,请参考以下文章
Asp.Net Core 上的 Razor 页面 - 添加了 Razor 页面但无法让页面显示