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.

Rojalin SahooRank #2,919 · 493 reputationPosted Aug 18, 2015, 1:10 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 18, 2015, 3:37 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Aug 18, 2015, 3:59 AM EDT
Rahul PrajapatRank #1,209 · 1.5K reputationPosted Aug 18, 2015, 4:19 AM EDT
function chng() {
document.getElementById('TextBox1').style.border = "2px solid #ff0000";
}
umair mohsinRank #3,092 · 463 reputationPosted Aug 18, 2015, 7:50 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 18, 2015, 8:06 AM EDT
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>
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 18, 2015, 8:24 AM EDT
<%@ 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.umair mohsinRank #3,092 · 463 reputationPosted Aug 18, 2015, 10:49 PM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 18, 2015, 10:53 PM EDT
Mohammed IbrahimRank #685 · 3.5K reputationPosted Aug 19, 2015, 1:33 AM EDT
Sandeep KumarRank #1,923 · 763 reputationPosted Aug 20, 2015, 1:09 AM EDT
$(document).ready(function(){
$("button").click(function(){
$("input").css({"border":"yellow 5px solid","background-color":"red"});
});
});
Munesh SharmaRank #174 · 13.9K reputationPosted Aug 20, 2015, 2:55 AM EDT
Vaikesh K PRank #808 · 2.8K reputationPosted Aug 20, 2015, 3:04 AM EDT
Check these links :