gpt4 book ai didi

javascript - 我想知道如何在后面的代码中访问我的模态表单元素。另外我想知道如何在模态表单上应用 jquery 验证器

转载 作者:行者123 更新时间:2023-12-03 00:31:40 28 4
gpt4 key购买 nike

我想知道如何在后面的代码中访问我的模态表单元素。另外我想知道如何在模态表单上应用 jquery 验证器。

我的网络表单代码如下

 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="HotelReservation.Views.test" %>

<!DOCTYPE html>
<style>
.modal-backdrop {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1030;
background-color: #333333;
opacity:0.5;

}
</style>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script src="../js/jquery-3.3.1.min.js"></script>
<script src="../js/jquery.validate.js"></script>
<script src="../js/jquery.validate.min.js"></script>
<script src="../js/bootstrap.js"></script>
<link href="../css/bootstrap.css" rel="stylesheet" />
<script src="../js/customLoginJS.js"></script>
<link href="../css/StyleSheetLoginPage.css" rel="stylesheet" />
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' />
<title>Login</title>
</head>

<body style="background-image:url('../images/f_img_132.png')" >


<div class="form-container" style="background-color: rgba(179, 179, 179,0.9); width: 23%; margin: auto; margin-top: 170px; padding-bottom: 60px; padding-top: 16px; border-radius: 20px; z-index: 100">

<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4"></div>
<form id="form1" runat="server" style="margin-top: 100px;">
<fieldset>
<legend style="font-family: 'Montserrat'">Login</legend>
<div class="form-group row">
<label for="staticEmail" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10">
<input type="text" readonly="" class="form-control-plaintext" value="email@example.com" />
</div>
</div>
<div class="form-group">
<label style="font-family: 'Montserrat'" for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" runat="server" aria-describedby="emailHelp" placeholder="Enter email" />
<small id="emailHelp" class="form-text text-muted-white">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label style="font-family: 'Montserrat'" for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" runat="server" placeholder="Password" />
</div>

<label id="error" runat="server" style="color: red"></label>
<br />

<button id="Button1" type="submit" runat="server" onserverclick="Button1_ServerClick" class="btn btn-outline-primary">Login</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#">Forgot Password?</a>
<br />
<br />
<%--<button type="submit" id="idSignUp" runat="server" class="btn btn-outline-primary">Sign Up</button>--%>
<div class="btn btn-outline-primary" data-toggle="modal" data-target="#mymodal">Sign Up</div>
</fieldset>
<div class="modal" id="mymodal">
<div class="modal-dialog" role="document" >
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" style="font-family: 'Montserrat'">Register</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<input type="text" class="form-control" id="name" placeholder=" Full Name" required="required"/>
</div>
<div class="form-group">
<input type="email" class="form-control" id="uname" placeholder="User Name" required="required"/>
</div>
<div class="form-group">
<input type="password" class="form-control" id="pwd" placeholder="Password" required="required"/>
</div>
<div class="form-group">
<input type="password" class="form-control" id="Password1" placeholder="Confirm Password" required="required"/>
</div>
<div class="form-group">
<input type="text" class="form-control" id="Text1" placeholder="City" required="required"/>
</div>
<div class="form-group">
<input type="text" class="form-control" id="Text2" placeholder="Country" required="required"/>
</div>
<div class="form-group">
<input type="text" class="form-control" id="Text3" placeholder="Zipcode" required="required"/>
</div>
<div class="form-group">

<input type="date" class="form-control" value="Enter birthday" name="bday" required="required"/>
</div>
<br />

</div>
<div class="modal-footer">
<button type="submit" runat="server" class="btn btn-warning" onserverclick="Unnamed_ServerClick">Register</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</form>



</div>
</div>

我的 jquery 验证器的 javascript 代码是这样的:-

 <script>
$(document).ready(function () {
var $validator = $("#form1").validate({
rules: {
uname: {
required: true,
email: true,
minlength: 3
}
}
})
});
</script>


</body>
</html>

我的代码背后部分是:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HotelReservation.Views
{
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Button1_ServerClick(object sender, EventArgs e)
{
string uname = exampleInputEmail1.Value;
}

protected void Unnamed_ServerClick(object sender, EventArgs e)
{
//here i want to access modal elements like the text box etc
}
}
}

提前致谢。请帮忙。我想要一个 jquery 验证器和模态元素的代码隐藏访问。

最佳答案

为了让它变得简单,只需使用 ajax 来完成您想做的任何事情。使用 ajax 访问服务器上的数据或在模式控件上设置数据。这将是最简单的。

关于javascript - 我想知道如何在后面的代码中访问我的模态表单元素。另外我想知道如何在模态表单上应用 jquery 验证器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53837080/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com