473,767 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Client side validation in asp.net forms

Hi

Has anyone any experience using client side validation with asp.net forms.

Specifically I'd like to know...

1. How do you attach client side code web controls (a button), like a
JavaScript 'onclick' event for example?
2. Any issues anyone has experienced using client side validation with
asp.net forms?

Thanks in advance

Simon Ames
Nov 18 '05 #1
4 4133
All validator controls run on the client side unless scripting in the client
browser is switched off. Hence using validator controls will be equivalent
to writing "Onclick" event code on the client side.
Krishnan

<am*******@hotm ail.com> wrote in message
news:eY******** ******@TK2MSFTN GP11.phx.gbl...
Hi

Has anyone any experience using client side validation with asp.net forms.

Specifically I'd like to know...

1. How do you attach client side code web controls (a button), like a
JavaScript 'onclick' event for example?
2. Any issues anyone has experienced using client side validation with
asp.net forms?

Thanks in advance

Simon Ames

Nov 18 '05 #2
Hi Simon,

Like you normally write a javascript and place it in regular place.
Only thing you have to do is.
for the button webcontrol add the following:
button.attribut e.add("onClick" ,"javascript:re turn click();")
This has to be put in the page load so that this function is available when
the page is loaded.
i think this is what you want.
Anything else do reply.
ARvind.
<am*******@hotm ail.com> wrote in message
news:eY******** ******@TK2MSFTN GP11.phx.gbl...
Hi

Has anyone any experience using client side validation with asp.net forms.

Specifically I'd like to know...

1. How do you attach client side code web controls (a button), like a
JavaScript 'onclick' event for example?
2. Any issues anyone has experienced using client side validation with
asp.net forms?

Thanks in advance

Simon Ames

Nov 18 '05 #3
Jos
Krishnan wrote:
All validator controls run on the client side unless scripting in the
client browser is switched off. Hence using validator controls will
be equivalent to writing "Onclick" event code on the client side.


Another condition is that the browser be IE.
ASP.NET client side validation doesn't work in Netscape.

--

Jos
Nov 18 '05 #4
The button controls always use the client-side onclick event themselves for
running the client-side validation. You cannot just use
Button1.Atttrib utes.Add("oncli ck", "[your code]")
Instead, set Button1.CausesV alidation = false to prevent it from generating
that code. Then add your code. If you want the client-side validation to
continue, the script is available by calling
Page.GetPostBac kClientReferenc e. For example:
Button1.Atttrib utes.Add("oncli ck", "[your code]" +
Page.GetPostBac kClientReferenc e(Button1, ""))

There are many issues with using client-side validation. In fact, there are
many issues with validation in general. I publish a replacement to
Microsoft's validations because there are so many limitations. Use this link
to see all the problems I found: http://www.peterblum.com/vam/valmain.aspx.
Even if you don't want my product ("Profession al Validation And More" -
http://www.peterblum.com/vam/home.aspx), this list will help you plan your
development efforts better.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

<am*******@hotm ail.com> wrote in message
news:eY******** ******@TK2MSFTN GP11.phx.gbl...
Hi

Has anyone any experience using client side validation with asp.net forms.

Specifically I'd like to know...

1. How do you attach client side code web controls (a button), like a
JavaScript 'onclick' event for example?
2. Any issues anyone has experienced using client side validation with
asp.net forms?

Thanks in advance

Simon Ames

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3252
by: Eric Linders | last post by:
Hi everyone. :-) Our site gets a ton of traffic on our contact forms, which collect the standard information (name, address, city, state, zip, home phone, etc.) The form validation is done with PHP. To eliminate (or at least deter) people wasting time submitting phony information, we can compare the state to the zip code (one DB table) and the zip code to the area code (another table in same DB).
4
2373
by: | last post by:
Hello Guys, I am using the validation controls to validate my data. But the problem is "The page is still being posted to server". I want to get rid of the round trips to server. Are there any get arounds for this problem apart from the traditional JavaScript?
14
6310
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2) show the error message next to the control. For example, if the text field is empty with RequiredField Validator control, it can show the value in ControlToValidate property in two ways as I mentioned. Please advise. Thanks!
5
2604
by: Mong | last post by:
Hi, I have a webform with various asp controls on it such as textboxes and dropdownlists. I'm fairly new to asp.net coming from VB6 and am wondering when it's best to use client side events and when it's best to use server side events. For example, if a textbox is to contain a date I want to validate the date when that textbox loses the focus. If the date is not valid I make visible a label next to the textbox telling the user it's
1
5240
by: rmgalante | last post by:
I have written an ASP.Net application that uses the standard client-side and server-side validation for various fields on the form. Some of the customers that use the form report symptoms that appear to be the result of double-clicking the submit button on the form. The form has three ASP:Button tags, each of which gets translated into INPUT TYPE="SUBMIT" HTML elements. One submits the form's data. One logs the user out. And the other...
5
1920
by: Sun Jian | last post by:
Hi, I am trying to customize the asp.net validation to achieve the following: Upon submitting the form, client side validation will run, and it will stop at the first error detected. For example if both UserID and Password text fields are required but neither is filled in, I'd like to display the error message (a dialogbox) "Please enter the User ID". And only after the user has filled in UserID, it will display "Please enter the...
3
2971
by: Guadala Harry | last post by:
I hope this is something I can solve without contacting the vendor: I'm implementing a 3rd party component that will, by itself, initiate a PostBack. Apparently it does not support the CausesValidation property - so forms get posted back without any client-side validation. I know I can do validation server side (and do anyway just as a good practice), but I want this control (which is basically an ImageButton) to trigger client-side...
9
2238
by: Alan Silver | last post by:
Hello, I have some simple client-side Javascript validation that was working fine until now. For some reason (don't ask me), it has stopped working and I can't figure out why. I have switched to version 2.0 (from 1.1) and have changed the page to use a master page, but other than that, it's the same. I am trying to validate the from date for a credit card to make sure the date has already passed. The code is pretty straightforward. I...
2
3856
by: goscottie | last post by:
I need to find a way to either 1. run and check all Validation controls (in my case one CompareValidator) and run client side javascript function. In this case I'll use <asp:Button>. So if all validation passes, run custom javascript. Or. 2. from my client side javascript to run Validation check and then perform remaining client side function. So in this case I'll use <input type="button">.
0
9571
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5279
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.