customvalidator do not work with empty fields

E

Eric Layman

Hi everyone,

I noticed that customevalidator won't work with empty fields. But I do not
want to put in another requiredfieldvalidator

Any workarounds?

I've tried

if args.Text.trim.length() = 0 then
args.isvalid = false
exit sub
end if
 
G

Guest

Hi everyone,

I noticed that customevalidator won't work with empty fields. But I do not
want to put in another requiredfieldvalidator

Any workarounds?

The ValidateEmptyText property, new in ASP.NET 2.0, fixes an issue
with CustomValidator. In ASP.NET 1.0 custom validation would not fire
if the text of the ControlToValidate was empty. You can set this
property to true to cause custom validation to occur for empty input
values.

For .NET 1.0 look at this thread
http://groups.google.com/group/micr...read/thread/1438177b1f3ee8fe/be36fdc5dba253cc
 
S

sloan

if this is javascript code.

if args.Text.trim.length() = 0 then
args.isvalid = false
exit sub
end if


then make sure you properties are correct.

js is case sensitive.

args.IsValid = false

is the correct way I think, but double check my case.



Eric Layman said:
Hi everyone,

I noticed that customevalidator won't work with empty fields. But I do not
want to put in another requiredfieldvalidator

Any workarounds?

I've tried

if args.Text.trim.length() = 0 then
args.isvalid = false
exit sub
end if
 
G

Guest

Howdy,

You have to set ValidateEmptyText property to true

<asp:CustomValidator runat="server" ID="cv" ValidateEmptyText="true"/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top