Home All Groups Group Topic Archive Search About

Required field validator

Author
21 Mar 2005 8:36 AM
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

Author
21 Mar 2005 11:32 AM
Jason Bentley
Srivivas, you will most likely have to use a RegularExpressionValidator
or CustomValidator to get the results you want.

Jason Bentley
http://geekswithblogs.net/jbentley
Are all your drivers up to date? click for free checkup

Author
21 Mar 2005 4:49 PM
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: PLB***@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

Show quoteHide quote
"Srinivas" <no.spam@email.com> wrote in message
news:ulYwBKfLFHA.1884@TK2MSFTNGP15.phx.gbl...
> 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
>
>
Author
21 Mar 2005 5:21 PM
Brock Allen
This is not the default behavior -- whitespace is trimmed prior to validation.
Can you post your ASPX?

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> 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
>



Post Thread options