my application has a textbox a validation control and a button control.i want that if textbox is empty and button i clicked i know the validator would work
but i also want to set border color,style property to the textbox control.how can i do this.
Vaikesh K PPosted Aug 20, 2015, 7:04 AM
Check these links :
Munesh SharmaPosted Aug 20, 2015, 6:55 AM
Sandeep KumarPosted Aug 20, 2015, 5:09 AM
$(document).ready(function(){
$("button").click(function(){
$("input").css({"border":"yellow 5px solid","background-color":"red"});
});
});
Mohammed IbrahimPosted Aug 19, 2015, 5:33 AM
Upendra Pratap ShahiPosted Aug 19, 2015, 2:53 AM
umair mohsinPosted Aug 19, 2015, 2:49 AM
Upendra Pratap ShahiPosted Aug 18, 2015, 12:24 PM
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test1.aspx.cs" Inherits="Test1" %>
DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>c# corner forumtitle>
<script type="text/javascript" language="javascript">
function validate() {
var txt = document.getElementById('<%= txtusername.ClientID %>');
var txt2 = document.getElementById('<%= txtpass.ClientID %>');
if (txt.value == "") {
txt.style.border = "1px solid Red";
return false;
}
if (txt2.value == "") {
txt2.style.border = "1px solid Red";
return false;
}
}
script>
head>
<body>
<form id="form1" runat="server">
<div style="width: 100%">
<div style="margin-bottom: 200px;">
div>
<div style="margin: 0px auto;">
<table width="100%">
<tbody>
<tr>
<td align="center">
<table border="0" width="400px">
<tbody>
<tr>
<td align="center">
<strong style="font-size: 18px;">User Loginstrong>
td>
tr>
<tr>
<td align="center">
<asp:TextBox ID="txtusername" Height="30px" Width="200px" runat="server">asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic" ValidationGroup="Submit" ControlToValidate="txtusername" ForeColor="Red" ErrorMessage="Enter UserName">asp:RequiredFieldValidator>
td>
tr>
<tr>
<td align="center">
<strong style="font-size: 18px;">Password strong>
td>
tr>
<tr>
<td align="center">
<asp:TextBox ID="txtpass" Height="30px" Width="200px" TextMode="Password" runat="server">asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Display="Dynamic" ValidationGroup="Submit" ControlToValidate="txtpass" ForeColor="Red" ErrorMessage="Enter Password">asp:RequiredFieldValidator>
td>
tr>
<tr>
<td align="center">
<asp:Button ID="Button1" runat="server" Text="Signin" OnClientClick="return validate();">asp:Button>td>
tr>
tbody>
table>
td>
tr>
tbody>
table>
div>
<div style="margin-top: 300px;">
div>
div>
form>
body>
html>
Kindly accept the answer.Upendra Pratap ShahiPosted Aug 18, 2015, 12:06 PM
DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>c# corner forumtitle>
<script type="text/javascript" language="javascript">
function validate() {
var txt = document.getElementById('<%= txtusername.ClientID %>');
var txt2 = document.getElementById('<%= txtpass.ClientID %>');
if (txt.value == "") {
txt.style.border = "1px solid Red";
return false;
}
if (txt2.value == "") {
txt2.style.border = "1px solid Red";
return false;
}
}
script>
head>
<body>
<form id="form1" runat="server">
<div style="width: 100%">
<div style="margin-bottom: 200px;">
div>
<div style="margin: 0px auto;">
<table width="100%">
<tbody>
<tr>
<td align="center">
<table border="0" width="400px">
<tbody>
<tr>
<td align="center">
<strong style="font-size: 18px;">User Loginstrong>
td>
tr>
<tr>
<td align="center">
<asp:TextBox ID="txtusername" Height="30px" Width="200px" runat="server">asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic" ValidationGroup="Submit" ControlToValidate="txtusername" ForeColor="Red" ErrorMessage="Enter UserName">asp:RequiredFieldValidator>
td>
tr>
<tr>
<td align="center">
<strong style="font-size: 18px;">Password strong>
td>
tr>
<tr>
<td align="center">
<asp:TextBox ID="txtpass" Height="30px" Width="200px" TextMode="Password" runat="server">asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Display="Dynamic" ValidationGroup="Submit" ControlToValidate="txtpass" ForeColor="Red" ErrorMessage="Enter Password">asp:RequiredFieldValidator>
td>
tr>
<tr>
<td align="center">
<asp:Button ID="Button1" runat="server" Text="Signin" OnClientClick="return validate();">asp:Button>td>
tr>
tbody>
table>
td>
tr>
tbody>
table>
div>
<div style="margin-top: 300px;">
div>
div>
form>
body>
html>
umair mohsinPosted Aug 18, 2015, 11:50 AM
Rahul PrajapatPosted Aug 18, 2015, 8:19 AM
function chng() {
document.getElementById('TextBox1').style.border = "2px solid #ff0000";
}
Rajeesh MenothPosted Aug 18, 2015, 7:59 AM
Upendra Pratap ShahiPosted Aug 18, 2015, 7:37 AM
Rojalin SahooPosted Aug 18, 2015, 5:10 AM