Click to See Complete Forum and Search --> : checking for emp num


SeGamysa
04-28-2003, 10:49 AM
Ok well I finished a questionaire.
and an added request was given to me.
they would like to add an emp num.
If the emp num is duplicated in the database the form should not submit.
So my form accesses the javascript validation script then submits.
but at this point in time it will only go threw to the javascript.

Is there a way to insert my asp.net code with my javascript code?
I would like the check for emp Num to run at the same time as Javascript validation.
Or is it possible to call a javascript function from an asp.net function?

-SeGa-

Bullschmidt
04-28-2003, 09:27 PM
Perhaps check this on the ASP page just before writing to the database. This is where I do most of my validating anyways.

SeGamysa
04-29-2003, 08:36 AM
is it possible then to have the server side populate an array on the form load and then have the javascript check for the values?

DaiWelsh
04-29-2003, 10:53 AM
Possible, but probably not practical

- how many emp numbers are you talking about, if it is a large number it is very wasteful to load them all into the js.
- are the emp numbers in any way tied to security, if so it is not good to expose them all like that.
- there is no guarantee another user elsewhere has not nabbed the employee number since the page was loaded. This is particularly true if the user saves the page or it is cached and reused later.
- What if the user does not have js or does not have it switched on, if this would break your application that is bad news.

As a general rule, I create all my validation first on the server side where I know it will always fire and always use the latest available information. After I am happy with that I may add javascript validation purely for user convenience and to spare load on the server.

HTH,

Dai

SeGamysa
04-29-2003, 01:38 PM
Well I did it on the load page that way everything gets done at once.
well
Thanks evryone for your help.
ciao
:D :D

DaiWelsh
04-29-2003, 05:04 PM
You can lead a horse to water....

but a pencil must be lead mate.

:rolleyes: