TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
nithin raj
NA
52
509
single textbox with different validation
May 29 2018 5:48 AM
<
div
class
=
"search-container"
>
<
label
>
<
br
/>
<
br
/>
<
br
/>
Sort By
</
label
>
<
asp:TextBox
ID
=
"txtsearch"
runat
=
"server"
placeholder
=
"Search by Product Name/Brand Name/Product Description...."
Width
=
"460px"
>
</
asp:TextBox
>
Price Min :
<
asp:TextBox
ID
=
"txtminprice"
ValidationGroup
=
"productvalidate"
runat
=
"server"
>
</
asp:TextBox
>
Max :
<
asp:TextBox
ID
=
"txtmaxprice"
ValidationGroup
=
"productvalidate"
runat
=
"server"
>
</
asp:TextBox
>
<
asp:CustomValidator
ID
=
"CustomValidator1"
runat
=
"server"
Display
=
"Dynamic"
ErrorMessage
=
"CustomValidator"
ForeColor
=
"Red"
ValidationGroup
=
"productvalidate"
OnServerValidate
=
"CustomValidator_ServerValidate"
>
</
asp:CustomValidator
>
<
asp:CompareValidator
ID
=
"CompareValidator1"
ForeColor
=
"Red"
runat
=
"server"
Display
=
"Dynamic"
ControlToValidate
=
"txtmaxprice"
ValidationGroup
=
"productvalidate"
ControlToCompare
=
"txtminprice"
operator
=
"GreaterThan"
type
=
"Double"
ErrorMessage
=
"max price must be grater than"
>
</
asp:CompareValidator
>
<
br
/>
<
br
/>
Date From :
<
asp:TextBox
ID
=
"txtdatefrom"
autocomplete
=
"off"
runat
=
"server"
>
</
asp:TextBox
>
<
cc1:CalendarExtender
ID
=
"CalendarExtender1"
Format
=
"yyyy-M-dd"
TargetControlID
=
"txtdatefrom"
runat
=
"server"
>
</
cc1:CalendarExtender
>
Date To :
<
asp:TextBox
ID
=
"txtdateto"
autocomplete
=
"off"
runat
=
"server"
>
</
asp:TextBox
>
<
cc1:CalendarExtender
ID
=
"CalendarExtender2"
TargetControlID
=
"txtdateto"
Format
=
"yyyy-M-dd"
runat
=
"server"
>
</
cc1:CalendarExtender
>
<
asp:CustomValidator
ID
=
"CustomValidator2"
runat
=
"server"
Display
=
"Dynamic"
ErrorMessage
=
"CustomValidator"
ForeColor
=
"Red"
ValidationGroup
=
"productvalidate"
OnServerValidate
=
"CustomValidator_ServerValidate1"
>
</
asp:CustomValidator
>
<
asp:CompareValidator
ID
=
"CompareValidator2"
runat
=
"server"
ControlToValidate
=
"txtdateto"
Display
=
"Dynamic"
ValidationGroup
=
"productvalidate"
ForeColor
=
"Red"
ControlToCompare
=
"txtdatefrom"
operator
=
"GreaterThan"
type
=
"Date"
ErrorMessage
=
"toDate must be grater than"
>
</
asp:CompareValidator
>
<
asp:CustomValidator
ID
=
"CustomValidator3"
runat
=
"server"
ErrorMessage
=
"CustomValidator"
ForeColor
=
"Red"
Display
=
"Dynamic"
ValidationGroup
=
"productvalidate"
OnServerValidate
=
"CustomValidator_ServerValidate2"
>
</
asp:CustomValidator
>
<
asp:ImageButton
ID
=
"btnsearchs"
style
=
"float:right"
OnClick
=
"btnsearchs_Click"
Height
=
"60px"
ValidationGroup
=
"productvalidate"
runat
=
"server"
ImageUrl
=
"~/Images/btnsearch.png"
/>
</
div
>
public
void
CustomValidator_ServerValidate(
object
source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
args.IsValid =
true
;
if
((txtminprice.Text !=
""
&& txtmaxprice.Text ==
""
) || (txtminprice.Text ==
""
&& txtmaxprice.Text !=
""
))
{
CustomValidator1.ErrorMessage =
"Enter value in at Both text Box"
;
args.IsValid =
false
;
}
}
public
void
CustomValidator_ServerValidate1(
object
source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
args.IsValid =
true
;
if
((txtdatefrom.Text !=
""
&& txtdateto.Text ==
""
) || (txtdatefrom.Text ==
""
&& txtdateto.Text !=
""
))
{
CustomValidator2.ErrorMessage =
"Enter value in at Both text Box"
;
args.IsValid =
false
;
}
}
public
void
CustomValidator_ServerValidate2(
object
source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{
args.IsValid =
true
;
if
((txtdatefrom.Text ==
""
&& txtdateto.Text ==
""
) && (txtminprice.Text ==
""
&& txtmaxprice.Text ==
""
) && (txtsearch.Text==
""
))
{
CustomValidator3.ErrorMessage =
"Select atleast one selection"
;
args.IsValid =
false
;
}
}
this is my code ,the problem is after showing error message ,reenter correct input but it always shown, after button click is working fine, please tell solution of this problem
Reply
Answers (
1
)
dynamic value changing svg progress bar in circle .
Unable to find sqlite database after publish .Net core 2.0