hello everybody:

i am new to VB.net I have to design a custom web server control which validates itself on client side and server-side. which means that i would not use a seperate custom validator for validation, but it should be a part of the custom control itself.and this validation would be done on clientside first, and incase javascript is off in browser then validation is done on server side.

The description of the custom control is as follows:

its a date control which has 3 dropdowns(dds).one for month, second for days and third for days.it has two properties isDOB(boolean) and getDate which returns the date in the format mm/dd/yyyy.
one method setDate which takes the string inn the format mm/dd/yyyy.This will set date according to the input string.

can somebody point me to the rite direction.any help would be deeply appreciated.

Thanks
Cheers!

AB


Aamir Babar

a) what does isDOB represent
b) what do you want to validate

a) what does isDOB represent
b) what do you want to validate

Thanks for ur reply.

here is the detail.

Actually this Date control wil have two types of behavior, and it will depend on this Public property IsDOB(is date of birth
) return type Boolean. if this is true, the date Dropdown(DD) will start from 1895 up to the current year -10.and as default year 1960 would be selected.it does not care about month DD and Day DD.

on the other hand if its false. Three dds will show the current date.while the year will start from 2002 up to current year.so this is the signaificance about IsDob.

Then r 2 other public properties.
public property GetDate() as string : return the date in the format mm/dd/yyyy.

one method:
SetDate(string) :set the date accordong to the input string.

Validation
----------

let say some one selects the sept month in month DD and day 31 in day dd. This should be validated first on the client side and then server side incase javascript fails(javascript is off).

other example would be leap year.some one select feb in leap year and 29 or more then 28 days in days DD.
So this kind of scinarios has to be validated.

i dont want to use a seperate custom validator for my control.
the validator cvontrol should be part of the date custom control itself.

if u still have any Qs please dont hasitate to ask me .
thanks


Ab

you can use a custom validator in .net or any of the built in ones. By default all validators run on the client and on the server if java is not enabled on the client, so that solves that problem straight away.

Depending on your exact needs you just need a few validators. To limit the dates in each box, you can use range validators. You can change the range depending on the DOB checkbox etc. You can also use a regex if you wish to check the whole date is valid too. Then use a summary to list all errors. Group them all together for the summary and link your postback button to the same group so they cannot click it until validated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.