473,410 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Required field validator

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
Nov 19 '05 #1
3 2098
Srivivas, you will most likely have to use a RegularExpressionValidator
or CustomValidator to get the results you want.

Jason Bentley
http://geekswithblogs.net/jbentley

Nov 19 '05 #2
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Srinivas" <no*****@email.com> wrote in message
news:ul**************@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

Nov 19 '05 #3
This is not the default behavior -- whitespace is trimmed prior to validation.
Can you post your ASPX?

-Brock
DevelopMentor
http://staff.develop.com/ballen
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


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Martin | last post by:
Dear Group It says in MSDN that a field can be associated with more than one validators but can one validator be associated with more than one field? Or do I need a validator for each field? How...
2
by: z. f. | last post by:
Hi, i have a field with required field validator. on the client side it's working. when i submit without the required field the page gets back because of not valid, but the message from the...
1
by: Brian Shannon | last post by:
I built a composit control consisting of a calandar control and a text box and an image of a calandar. Depending on what page I place this control the Date field needs to be required. If the...
1
by: Sam Collett | last post by:
Is there a way of having a required field validator check to see if at least one of a set of controls has information in it? I'm sure this can somehow be done using a custom validator, but would...
2
by: pmud | last post by:
Hi, I have an ASP.Net web page . The page was working fine until I added a required field field validator. My page has a link button which takes the user to another page, a submit button which...
3
by: Skeptical | last post by:
Hello, I have a form and two buttons on it. Button1 submits the data to a database and RequiredFieldValidator is used to make sure all the required fields are filled up, the second button has a...
2
by: David Hearn | last post by:
I have some required field validators on a form and would like to know if there is a way to set focus back to the field that is required if the validator is triggered. The problem is that the...
3
by: Kivak Wolf | last post by:
Hi, Could someone give me a quick review of how to use the required field Validator? I'm completely at a loss, and MSDN does not help one bit. =/ Basically all I want done is to make sure that...
3
by: Mike Collins | last post by:
Is it possible to use a required field validator and have it make a user answer a comment field based on a drop down value picked? For instance, if the user selects "It was terrible", make them...
0
by: nimeshdotnet | last post by:
Hi All, I have a textbox whose readonly property is set to true. This textbox is also guarded by a required field validator. What i m doing that I have a calendar control whose on date selection i...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.