473,404 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

ValidatorOnSubmit - Client Side Validation

For client side validation, the following code is generated by the framework
<form name="Form1" method="post" onsubmit=" if (!ValidatorOnSubmit()) return
false; MyFunction...">
My Problem is that, I need to call another javascript function regardless of
whether or not ValidatorOnSubmit() is true or false (i.e client side
validation fails or passes). My WebUIValidation.js has
function ValidatorCommonOnSubmit() {
var result = !Page_BlockSubmit;
Page_BlockSubmit = false;
event.returnValue = result;
return result;
}
But still my form has onsubmit = "if (!ValidatorOnSubmit()) return false;
MyFunction()"
Hence MyFunction() is not being called when the validation fails. I want it
to be called everytime.. how can I change this so that my function is also
called??
Any help will be appreciated..

Nov 19 '05 #1
3 12683
You can use the method Page.RegisterOnSubmitStatement method for this e.g. in
Page_Load:

this.RegisterOnSubmitStatement("MyMethod", "MyMethod();");

The client-side call to MyMethod is then places before the call to
ValidatorOnSubmit in the onsubmit event for the form tag.

HTH, Jakob.

"deride" wrote:
For client side validation, the following code is generated by the framework
<form name="Form1" method="post" onsubmit=" if (!ValidatorOnSubmit()) return
false; MyFunction...">
My Problem is that, I need to call another javascript function regardless of
whether or not ValidatorOnSubmit() is true or false (i.e client side
validation fails or passes). My WebUIValidation.js has
function ValidatorCommonOnSubmit() {
var result = !Page_BlockSubmit;
Page_BlockSubmit = false;
event.returnValue = result;
return result;
}
But still my form has onsubmit = "if (!ValidatorOnSubmit()) return false;
MyFunction()"
Hence MyFunction() is not being called when the validation fails. I want it
to be called everytime.. how can I change this so that my function is also
called??
Any help will be appreciated..

Nov 19 '05 #2
Try this...

var temp; if(!ValidatorOnSubmit()) temp = false; MyFunction(); if(temp ==
false) return temp;

Brad.

"deride" wrote:
For client side validation, the following code is generated by the framework
<form name="Form1" method="post" onsubmit=" if (!ValidatorOnSubmit()) return
false; MyFunction...">
My Problem is that, I need to call another javascript function regardless of
whether or not ValidatorOnSubmit() is true or false (i.e client side
validation fails or passes). My WebUIValidation.js has
function ValidatorCommonOnSubmit() {
var result = !Page_BlockSubmit;
Page_BlockSubmit = false;
event.returnValue = result;
return result;
}
But still my form has onsubmit = "if (!ValidatorOnSubmit()) return false;
MyFunction()"
Hence MyFunction() is not being called when the validation fails. I want it
to be called everytime.. how can I change this so that my function is also
called??
Any help will be appreciated..

Nov 19 '05 #3
Thanks a million Jakob.. it works.. however, I wonder what is the difference
between RegisterStartUpScript and form.Attributes["OnSubmit"].
Earlier I was using the following code in Page_Load
if ( form.Attributes["onsubmit"] == null)
{
form.Attributes.Add("onsubmit", " " +"MyMethod()");
}
and it was placing the call after the validation script call.. strange.
Anyways It works now, just curious about the difference.. thanks much..

"Jakob Christensen" wrote:
You can use the method Page.RegisterOnSubmitStatement method for this e.g. in
Page_Load:

this.RegisterOnSubmitStatement("MyMethod", "MyMethod();");

The client-side call to MyMethod is then places before the call to
ValidatorOnSubmit in the onsubmit event for the form tag.

HTH, Jakob.

"deride" wrote:
For client side validation, the following code is generated by the framework
<form name="Form1" method="post" onsubmit=" if (!ValidatorOnSubmit()) return
false; MyFunction...">
My Problem is that, I need to call another javascript function regardless of
whether or not ValidatorOnSubmit() is true or false (i.e client side
validation fails or passes). My WebUIValidation.js has
function ValidatorCommonOnSubmit() {
var result = !Page_BlockSubmit;
Page_BlockSubmit = false;
event.returnValue = result;
return result;
}
But still my form has onsubmit = "if (!ValidatorOnSubmit()) return false;
MyFunction()"
Hence MyFunction() is not being called when the validation fails. I want it
to be called everytime.. how can I change this so that my function is also
called??
Any help will be appreciated..

Nov 19 '05 #4

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

Similar topics

4
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...
14
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)...
4
by: | last post by:
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...
1
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...
5
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...
1
by: vidya | last post by:
Hi, I have a button which is a web control. I have some validation in javascript for the button in .aspx file and some in the button onclick event in code behind(C#). I need to get through both...
1
by: Hong Hao | last post by:
Recently, I was trying to modify an existing aspx page when client-side validation on that page stopped working. I searched this group and the web in general and found that other people have had...
2
by: rm1234 | last post by:
All, I am using XmlHttp / PageMethods to refresh a portion of web page that contains some asp.net validators that are enabled for client side validation. But before I submit Ajax post request I...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.