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
Guest User
Tech Writer
2.1k
480.7k
How to validate texbox using asp.net bootstrap error?
Mar 18 2020 3:54 AM
Hi Team
I am having a form with textbox and dont know how to validate the textbox, the validation has to happens when user leaves the form with empty field inserted. Message " This field is required". Here is my logic but its not validating and need some help.
<div
class
=
"row"
>
<label
for
"Email"
>Email:</label>
<div
class
=
"input-group col-md-4 col-md-offset-2 col-sm-2 col-xs-2"
>
<div
class
=
"input-group pull-right"
>
@Html.TextBoxFor(m => m.Email,
new
{ @
class
=
"form-control"
, type =
"text"
, id =
"email"
, autofocus =
"autofocus"
, placeholder =
"
[email protected]
"
, required =
"required"
})
<div
class
=
"input-group-append"
>
<div
class
=
"input-group-text"
>
</div>
</div>
</div>
</div>
</div>
div
class
=
"input-group mb-2"
>
<div
class
=
"input-group-append"
>
</div>
<div
class
=
"input-group col-md-4 col-md-offset-2 col-sm-2 col-xs-2"
>
<div
class
=
"input-group pull-right"
>
@Html.TextBoxFor(m => m.Code,
new
{
@
class
=
"form-control"
,
type =
"text"
,
id =
"postal code"
,
autofocus =
"autofocus"
,
placeholder =
"Postal / Zip Code"
,
required =
"required"
,
pattern = @
"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$"
,
title =
"This field is required"
})
<div
class
=
"input-group-append"
>
<div
class
=
"input-group-text"
>
</div>
</div>
</div>
</div>
</div>
Reply
Answers (
6
)
System.ArgumentNullException:Object reference not set?
How to align your texbox accordingly same width?