Skip to content

Commit 490e89d

Browse files
committed
Added Disabled Login Button Feature to both Login Panels such that the Login Button is only enabled whenever both TextFields aren't empty as well as changed error message color for the Customer Login Panel.
1 parent ea2b3b1 commit 490e89d

File tree

2 files changed

+51
-8
lines changed

2 files changed

+51
-8
lines changed

WebApplication2/Customer/Pages/login.aspx

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,17 @@
6969
margin-top: 10px;
7070
}
7171
72-
.login-container input[type="submit"]:hover,
72+
/*.login-container input[type="submit"]:hover,*/
7373
.login-container .login-button:hover {
7474
background-color: #6a11cb;
7575
}
7676
77+
.login-container .login-button:disabled {
78+
background-color: #2575fc; /* Original color */
79+
filter: brightness(0.8); /* Darkens the button */
80+
cursor: not-allowed;
81+
}
82+
7783
.forgot-password {
7884
margin-top: 10px;
7985
font-size: 12px;
@@ -86,7 +92,7 @@
8692
}
8793
8894
.error-message {
89-
color: #6a11cb;
95+
color: #2e4c5d;
9096
font-size: 14px;
9197
margin-top: 10px;
9298
}
@@ -144,14 +150,14 @@
144150
<form id="form1" runat="server" class="login-container">
145151
<h2>Customer Login</h2>
146152
<!-- Mobile Number Field -->
147-
<asp:TextBox ID="mnumber" runat="server" placeholder="Mobile Number" type="text"></asp:TextBox>
153+
<asp:TextBox ID="mnumber" runat="server" placeholder="Mobile Number" type="text" onkeyup="validateForm()"></asp:TextBox>
148154

149155
<!-- Password Field -->
150-
<asp:TextBox ID="password" runat="server" placeholder="Password" type="password"></asp:TextBox>
156+
<asp:TextBox ID="password" runat="server" placeholder="Password" type="password" onkeyup="validateForm()"></asp:TextBox>
151157

152158
<!-- Login Button -->
153159
<div>
154-
<asp:Button ID="buttonlogin" runat="server" onclick="loginm" Text="Login" CssClass="login-button" />
160+
<asp:Button ID="buttonlogin" runat="server" onclick="loginm" Text="Login" CssClass="login-button" Enabled="false" />
155161
</div>
156162
<br />
157163
<div>
@@ -188,5 +194,21 @@
188194
showPopup();
189195
}
190196
}
197+
198+
// Function to validate the form
199+
function validateForm() {
200+
var mnumber = document.getElementById('<%= mnumber.ClientID %>').value;
201+
var password = document.getElementById('<%= password.ClientID %>').value;
202+
var buttonlogin = document.getElementById('<%= buttonlogin.ClientID %>');
203+
204+
if (mnumber.trim() !== "" && password.trim() !== "") {
205+
buttonlogin.disabled = false;
206+
buttonlogin.style.cursor = 'pointer';
207+
} else {
208+
buttonlogin.disabled = true;
209+
buttonlogin.style.cursor = 'not-allowed';
210+
}
211+
}
212+
191213
</script>
192214
</html>

WebApplication2/Pages/Login/Login.aspx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
background: #D81B60;
5959
}
6060
61+
.login-button:disabled {
62+
background-color: #E91E63; /* Original color */
63+
filter: brightness(0.8);
64+
cursor: not-allowed;
65+
}
66+
6167
.error-message {
6268
color: #E91E63;
6369
font-size: 14px;
@@ -137,11 +143,11 @@
137143
<body>
138144
<form id="form1" runat="server" class="login-container">
139145
<h2>Admin Login</h2>
140-
<input id="txtUsername" runat="server" type="text" placeholder="AdminID" />
146+
<input id="txtUsername" runat="server" type="text" placeholder="AdminID" onkeyup="validateForm()" />
141147
<br />
142-
<input id="txtPassword" runat="server" type="password" placeholder="Password" />
148+
<input id="txtPassword" runat="server" type="password" placeholder="Password" onkeyup="validateForm()" />
143149
<br />
144-
<asp:Button ID="btnLogin" runat="server" CssClass="login-button" Text="Login" OnClick="LoginButton" />
150+
<asp:Button ID="btnLogin" runat="server" CssClass="login-button" Text="Login" OnClick="LoginButton" Enabled="false" />
145151
<div>
146152
<asp:Label ID="lblError" runat="server" CssClass="error-message"></asp:Label>
147153
</div>
@@ -177,5 +183,20 @@
177183
showPopup();
178184
}
179185
}
186+
187+
// Function to validate the form
188+
function validateForm() {
189+
var txtUsername = document.getElementById('<%= txtUsername.ClientID %>').value;
190+
var txtPassword = document.getElementById('<%= txtPassword.ClientID %>').value;
191+
var buttonlogin = document.getElementById('<%= btnLogin.ClientID %>');
192+
193+
if (txtUsername.trim() !== "" && txtPassword.trim() !== "") {
194+
btnLogin.disabled = false;
195+
btnLogin.style.cursor = 'pointer';
196+
} else {
197+
btnLogin.disabled = true;
198+
btnLogin.style.cursor = 'not-allowed';
199+
}
200+
}
180201
</script>
181202
</html>

0 commit comments

Comments
 (0)