Required field validator

S

Srinivas

Hi

If a textbox is being validated using a required field validator then we
need to key in some text before sumbmitting the form. But if we key in a
space character this gets validated to true and the form gets submitted. I
want to make sure that the user enters some text and submit the form, and
not just enter a space character and submitting the form. Any ideas how to
achieve this.

Thanks,

Srinivas
 
P

Peter Blum

You are saying that a single space character allows a RequiredFieldValidator
to accept the text? That is incorrect. The RequiredFieldValidator and all
other validators strip off lead and trailing spaces before evaluating text.
A single space would be eliminated and the field would be considered blank.

So if a single space is causing it to be accepted, something else is wrong.
Consider these issues:
1. Client-side validation isn't running or the submit button has
causesValidation=false. That means the page will submit without checking the
textbox.
2. On the server side, the submit button's OnClick method automatically
validates before calling your Click event. It will not do this when
CausesValidation is false. Users also forget to check for Page.IsValid in
the Click event method before saving data.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
B

Brock Allen

This is not the default behavior -- whitespace is trimmed prior to validation.
Can you post your ASPX?
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top