Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > A question about validator!

Reply
Thread Tools

A question about validator!

 
 
Nicky
Guest
Posts: n/a
 
      01-18-2005
I am new on asp.net programming.
Here I got a problem about validator
I want to write a login.aspx page, for example, there is UserName box. I
need to validate two things on UserName box,
1. It must be filled. If it is empty, I will show a red message right
after
this box, like "UserName is empty!"
2. It must be a valid user in our database. So on server side, we will
check
this UserName in our database. If it is not in our database, we will show
something like "Invalid user name..."
I know it is very easy to do the 1st rule with the RequireFieldValidator.
But in order to do the rule 2, I need to put a Lable at the same place
where
the validator is. Right? But the two won't stay at the same place. So I
tried
to use a CustomValidator, and write the ClientValidationFunction like
this:
<script language="javascript">
function ValidUserName(oSrc, args) //For rule 1
{
if(args.Value.length > 0)
args.IsValid = true;
else
args.IsValid = false;
}
</script>
And also, I have a server validate function which will process the rule 2.
But the problem is the client validate function never get called. So , do
you guys have better solution for this? I really appreciated.

 
Reply With Quote
 
 
 
 
Nicky
Guest
Posts: n/a
 
      01-19-2005
Thenk you peter!

"Peter Blum" wrote:

> When you need to do a database lookup to validate, do not use client-side
> validation at all. Database lookups are a feature of ASP.NET, not the
> browser. So use your customvalidator without the ClientValidationFunction
> but with the server side validation method doing all of the work.
>
> As a rule, all validation should work fully on the server side. Client-side
> validation is an optimization but is not available when the user turns off
> javascript or using any browser that does not support DHTML. (IE and IE/Mac
> are DHTML browsers; Mozilla and its kin are not.)
>
> So in your Click event handler method, always test Page.IsValid is true
> before proceeding.
>
> If you need client-side validation support on more than just DHTML browsers,
> use my solution: "Professional Validation And More"
> (http://www.peterblum.com/vam/home.aspx)
>
> --- Peter Blum
> www.PeterBlum.com
> Email: http://www.velocityreviews.com/forums/(E-Mail Removed)
> Creator of "Professional Validation And More" at
> http://www.peterblum.com/vam/home.aspx
>
> "Nicky" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I am new on asp.net programming.
> > Here I got a problem about validator
> > I want to write a login.aspx page, for example, there is UserName box. I
> > need to validate two things on UserName box,
> > 1. It must be filled. If it is empty, I will show a red message right
> > after
> > this box, like "UserName is empty!"
> > 2. It must be a valid user in our database. So on server side, we will
> > check
> > this UserName in our database. If it is not in our database, we will show
> > something like "Invalid user name..."
> > I know it is very easy to do the 1st rule with the RequireFieldValidator.
> > But in order to do the rule 2, I need to put a Lable at the same place
> > where
> > the validator is. Right? But the two won't stay at the same place. So I
> > tried
> > to use a CustomValidator, and write the ClientValidationFunction like
> > this:
> > <script language="javascript">
> > function ValidUserName(oSrc, args) //For rule 1
> > {
> > if(args.Value.length > 0)
> > args.IsValid = true;
> > else
> > args.IsValid = false;
> > }
> > </script>
> > And also, I have a server validate function which will process the rule 2.
> > But the problem is the client validate function never get called. So , do
> > you guys have better solution for this? I really appreciated.
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments