473,396 Members | 1,734 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,396 software developers and data experts.

Validate before JScript

ASP.NET 1.1

I have WebForm button with JScript, but I want to validate the form before
the JScript runs when the user clicks on the button, how to I do that?

this.butCreateLetter.Attributes.Add("onClick", "return CreateLetter();");

Thank You
Peter
Jan 26 '06 #1
9 1255
You pretty much have to output the javascript you want to run inside your
button's event handler.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Peter" <pc*****@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
ASP.NET 1.1

I have WebForm button with JScript, but I want to validate the form before
the JScript runs when the user clicks on the button, how to I do that?

this.butCreateLetter.Attributes.Add("onClick", "return CreateLetter();");

Thank You
Peter

Jan 26 '06 #2
this.butCreateLetter.Attributes.Add("onClick", "if
(typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); return
CreateLetter();");
Jan 26 '06 #3

"Mark Newmister" <mn********@iwanttss.com> wrote in message
news:OF**************@TK2MSFTNGP11.phx.gbl...
this.butCreateLetter.Attributes.Add("onClick", "if
(typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); return
CreateLetter();");


Thank You very much.

I have one more question

If validation fails how do I stop it from running the CreateLetter()
function?
Thanks


Jan 26 '06 #4
that'll only work for client-side validation. Ie, it won't work in firefox..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Mark Newmister" <mn********@iwanttss.com> wrote in message
news:OF**************@TK2MSFTNGP11.phx.gbl...
this.butCreateLetter.Attributes.Add("onClick", "if
(typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); return
CreateLetter();");

Jan 26 '06 #5

"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:Oa**************@TK2MSFTNGP14.phx.gbl...
that'll only work for client-side validation. Ie, it won't work in
firefox..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Mark Newmister" <mn********@iwanttss.com> wrote in message
news:OF**************@TK2MSFTNGP11.phx.gbl...
this.butCreateLetter.Attributes.Add("onClick", "if
(typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); return
CreateLetter();");



yes I am aware of it, this webpage is for Intranet and this webpage uses
ActiveX to open Word template so user has to use IE.

I have found the solution to stop executing JScript when validation fails:

System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("if (typeof(Page_ClientValidate) == 'function') { ");
sb.Append("if (Page_ClientValidate() == false) { return false } else {return
CreateLetter(); }} ");
Thank you for all the help!!!
Jan 26 '06 #6
>> that'll only work for client-side validation.

I thought that was what he wanted.
Ie, it won't work in firefox


Hmmm...works for me using this FF version:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111
Firefox/1.5
Jan 26 '06 #7
....however, I just realized that I'm using 2.0 and he mentioned 1.1. Would
this be the difference?

"Mark Newmister" <mn********@iwanttss.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
that'll only work for client-side validation.
I thought that was what he wanted.
Ie, it won't work in firefox


Hmmm...works for me using this FF version:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111
Firefox/1.5

Jan 26 '06 #8

"Mark Newmister" <mn********@iwanttss.com> wrote in message
news:O0**************@TK2MSFTNGP14.phx.gbl...
...however, I just realized that I'm using 2.0 and he mentioned 1.1.
Would this be the difference?

"Mark Newmister" <mn********@iwanttss.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
that'll only work for client-side validation.


I thought that was what he wanted.
Ie, it won't work in firefox


Hmmm...works for me using this FF version:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111
Firefox/1.5


It works in 1.1 just as well
Jan 26 '06 #9
Yes, validators in 1.1 won't work in Firefox, in 2.0 they do (client-side
that is).

Looks like you are right, IE only on an intranet..though I see no where in
the original post where that was stated :P lucky guess ;)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Mark Newmister" <mn********@iwanttss.com> wrote in message
news:O0**************@TK2MSFTNGP14.phx.gbl...
...however, I just realized that I'm using 2.0 and he mentioned 1.1.
Would this be the difference?

"Mark Newmister" <mn********@iwanttss.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
that'll only work for client-side validation.


I thought that was what he wanted.
Ie, it won't work in firefox


Hmmm...works for me using this FF version:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111
Firefox/1.5


Jan 26 '06 #10

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

Similar topics

20
by: Harag | last post by:
Hi All. I'm stating out doing some web developing. I was wondering which of the server side languages should I concentrate on and learn. I Know CSS, HTML, T-SQL I can look at the client...
4
by: Harag | last post by:
Hi All I currently thinking of converting from my little knowledge of VBscript to jScript ASP. With this in mind I'm looking at my current code to see how it will convert over to Jscript. ...
5
by: Andrew | last post by:
Hi, How can I validate a date, like 3/26/04, before submitted? Thanks for any idea. -- Andrew
1
by: QuantDev | last post by:
Hi NG, I would need to validate an XML fragment against a type defined within an XSD (which defines many other things). What is the correct way of achieving this? QD2004
1
by: charliewest | last post by:
Is it possible to use the custom validation control to validate a calendar control via client-side script (in jscript)? I'm familiar with custom validation and client side script, and i am aware...
6
by: RFS666 | last post by:
Hello, After I posted yesterday "using C# class in jscript", I have a new problem: I have a C# class - DBResult - that contains (and other variables) a string array (and other variables), that...
5
by: Maxwell2006 | last post by:
Hi, I have a requirement to develop an application component using only Server-Side Jscript (not Jscript.NET). What is Server-Side Jscript?
1
by: Andrew Wan | last post by:
How can VBScript code access JScript code variables in the same ASP page? <SCRIPT LANGAUGE="VBScript"> Dim a a = 10 </SCRIPT> <SCRIPT LANGUAGE="JScript"> Response.Write(a); </SCRIPT>
4
by: somuchbetta | last post by:
Hiya, Does anyone know any simple JScript code to validate a numeric field and also the length of the data that should be entered into the field. e.g. 12345 - the user can only enter numeric...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.