Javascript and validation

M

M@

Hi,
it's possible to append a custom action
to a client-side verification of a validation control ?
I have a validator summary control that shows
(automatically) a message box if the validation
of the validators in the page fails; after the user close this
message box I have to perform a client-side function
(hiding some text) ... it's possible?

Thanks!

M
 
P

Peter Blum

The Microsoft Validation framework does not offer any hooks where you can
take a post-validation action. You will have to invent a hack.

Alternatively, you can switch to "Professional Validation And More"
(http://www.peterblum.com/vam/home.aspx). It is a replacement to Microsoft's
validators that overcomes numerous limitations and addresses the many
features users have asked for with validation.
For example:
1. Every validator has a new property called the Enabler where you establish
a rule that determines if the validator shows or not. This may apply to your
problem.
2. It supports a concept called "validation groups". This allows multiple
submit buttons on the page to fire only their own validators.
3. It has a hook that is called after validation is performed. You insert
your javascript and attach it to the hook.
4. It includes a control called the FieldStateController. Its job is to
monitor clicks on controls and change the settings of other controls. It can
show and hide fields easily.
All of this is multibrowser compatible, supporting far more browsers than
Microsoft's do. (Microsoft's is limited to DHTML browsers: IE and IE/Mac).

Download a free trial version to investigate further and drop me an email if
you have any questions.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
D

Dan Bass

The Microsoft Validation framework does not offer any hooks where you can
take a post-validation action. You will have to invent a hack.

While the .Net framework does not do anything after validation, it's not
difficult to create a client side javascript function that will throw an
alert when called, and then perform some action on the web page (in this
case, hiding some text) after that.
 
M

M@

Let me know if you need anyhelp.

Hi,
thanks for yours links, I read them and I found them very very
interesting....
My problem is very simple : if you add a Client-side function
to a button
myButton.attributes["onclick"] = "some_function";
..net render this in this way:
<input type=button ........ onclick="some_function">
but if you have a validator on the page asp.net adds after
some_function the javascript code to validate the page...
I would like this behavior:
first validation occurs
after this some_function is called

Thanks you

M
 
D

Dan Bass

Perhaps I'm missing something, but why not scrap asp.net validation and call
your javascript client side validator function in your "some_function" code?

Validation in ASP.Net is a client side check on the server side control
values (that is the values of controls at the client before they are passed
back to the server) before a postback occurs, normally as a result of a
postback action (eg. server side button). If you have a client side button
(does not perform a post back) then the validation is not for you, and you
simply need to call your validation from your client side code.

If this doesn't work for you, post your code and we'll see if we can help.
What validation do you want to perform?
Why aren't you wanting to perform a postback with the button click (why's
the button not server side)?

Thanks.

Daniel.


M@ said:
Let me know if you need anyhelp.

Hi,
thanks for yours links, I read them and I found them very very
interesting....
My problem is very simple : if you add a Client-side function
to a button
myButton.attributes["onclick"] = "some_function";
.net render this in this way:
<input type=button ........ onclick="some_function">
but if you have a validator on the page asp.net adds after
some_function the javascript code to validate the page...
I would like this behavior:
first validation occurs
after this some_function is called

Thanks you

M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top