Hello Nathan,
I appriciate your response on this and the same time I am admit that
its been delayed in responding to this posting as I have been occupied
with other stuff. I am sorry about that.
Now, the server side event handling worked good for my _txtVIN text
box. here is the code
************************************************** ************************
Protected Sub _CustvldVIN_ServerValidate(ByVal source As Object, ByVal
args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles
_CustvldVIN.ServerValidate
If _txtVIN.Text.Length = 8 Then
args.IsValid = True
Else
args.IsValid = False
_CustvldVIN.Text = "Please enter CUST valid VIN"
End If
End Sub
************************************************** ***********************
and I put the
If page.isValid then
End if
code in the _btn_search_click event and it returns false if length is
less than 8.
But when I try doing it using Javascript it validates the txt entere
the _txtVIN text box but it generates a java script error on the left
bottom of the browser
it says "Object expected" when I double clicked on the error. I am not
sure if this some thing to do with Internet explorer IE 7.0 (beta
version) I am using.
Here is the defenition of the CustomValidator control in my .aspx page
************************************************** ********************************************
<asp:CustomValidator ID="_CustvldVIN" runat="server"
ControlToValidate="_txtVIN"
ErrorMessage="Please enter Cusvld VIN!"
OnServerValidate="_CustvldVIN_ServerValidate"
ClientValidationFunction="TestVIN">
</asp:CustomValidator>
************************************************** ********************************************
and the java script function that I have in my common.js script file is
************************************************** **************************************************
function TestVin(source,args)
{
if(args.value.length==

args.IsValid=true;
else
args.IsValid=false;
}
************************************************** **************************************************
Am I missing some thing here?
Please advice,
Thanks
-L
Nathan Sokalski wrote:
> My suggestion for both of these problems would be to use the CustomValidator
> control. For your first problem, I would use the following as your
> server-side event and the CustomValidator's ClientValidationFunction
> property:
>
> Sub val8Chars_ServerValidate(source As Object, args As
> ServerValidateEventArgs) Handles val8Chars.ServerValidate
> If txtMyTextBox.Text.Length = 8 Then args.IsValid = True Else args.IsValid
> = False
> End Sub
>
> <script type="text/javascript">
> function val8Chars_ServerValidate(source,args)
> {
> if(args.value.length==
> args.IsValid=true;
> else
> args.IsValid=false;
> }
> </script>
>
>
> For your second problem, I would use the following server-side event:
>
> Sub valMustPickOne_ServerValidate(source As Object, args As
> ServerValidateEventArgs) Handles valMustPickOne.ServerValidate
> If txtMyTextBox1.Text = "" AndAlso txtMyTextBox2.Text = "" AndAlso
> txtMyTextBox3.Text = "" Then args.IsValid = False Else args.IsValid = True
> End Sub
>
> If you wanted to make a ClientValidationFunction function for this, I would
> suggest generating it dynamically using the ClientID property of the three
> controls and adding the script using the RegisterClientScriptBlock method
> because the validation involves the value of multiple controls. for more
> information on how to do this, see the ASP.NET documentation and JavaScript
> documentation. Good Luck!
> --
> Nathan Sokalski
>
> http://www.nathansokalski.com/
>
> "Learner" <> wrote in message
> news: oups.com...
> > Hi Friends,
> > I have two things that I am running short of ideas on how to solve.
> > I am working on medium sized search form where in I will have to do
> > considerable validations befor it submits the form.
> >
> > 1).I have to put a validation on a text box ( _txtVIN ) such that it
> > min and max charecters should be 8. In other words user shouldn't be
> > able to enter more than 8 charecters of the total VIN numner. At the
> > same user must enter 8 charecters if at all he eneters some thing in
> > the text field. I have put the max length property to put a cap on the
> > number of charectors entered. But no clue how do I do it in the case
> > min of 8 charecters?
> >
> > 2). I have 3 text boxes. I need to make sure that atleast one filed has
> > the text in it before it submits the form. In other words user must
> > enter atleast a value in any of the text boxes. I am not sure what
> > control would do best to do this?
> >
> > say _txtYear, _txtMake, _txtModel and the form shoudln't submit unless
> > user provides atleast a value in the respective fileds.
> >
> >
> > Any inputs is greatly appreciated,
> > Thanks,
> > -L
> >