A question about asp.net Validator

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Nicky (Nicky_at_discussions.microsoft.com)
Date: 01/18/05


Date: Mon, 17 Jan 2005 20:55:01 -0800

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.



Relevant Pages

  • Re: I need help - Newbie stuck ( php check form input )
    ... test and is unlikely to be the correct input. ... validation of the data before insert into a database would be a very ... to directly retrieve the username again (assuming it will be used to ... if you are needing to validate just an integer input ...
    (comp.lang.php)
  • Re: I need help - Newbie stuck ( php check form input )
    ... test and is unlikely to be the correct input. ... validation of the data before insert into a database would be a very ... to directly retrieve the username again (assuming it will be used to ... if you are needing to validate just an integer input ...
    (comp.lang.php)
  • Re: Elevate privileges in a program
    ... >> I need to use $GETUAI to validate a username and password. ... someone from modifying the original data file in the public directory ...
    (comp.os.vms)
  • Re: Any Way to Validate Username & Password from an Application?
    ... advanced privileges, e.g., granting certain kinds of exceptions to the ... is necessary to validate the username and password for several reasons. ... VMS identifiers (rights) granted to users are ideal for this - you can ...
    (comp.os.vms)
  • Re: Java GUI Problem
    ... //While the user is not valid the keep object of the GUI class ... //following methods try to validate anything at all. ... //String userName gets the input for the ... //user name from the login class. ...
    (comp.lang.java.programmer)