471,049 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

clientside javascript validation for form

TJS
how do I get "onSubmit" to work in .net ?

<Form id="Form1" name="Form1" method="post" onSubmit="return
validateStandard(this, 'error');" runat="server">
Nov 18 '05 #1
4 2423
depends on how you want to do it.
right now you form is marked as run at server which means you will have to
rely on other controls to initiate a postback.

what you are using is a bog standard asp technique which is not normally
used with asp.net

in asp.net you have 5 validator objects from custom validtor (to implement
your own validtion on a particular control etc. or things like Required
Field Validation, compare validator, range validatior and regular
expressions validator. You have a validation summary object to display a
list of errors or display them in tabular format. with your form as it
stands right now you will have use add a Button or a ImageButton or a
Linkbutton (which are webcontrols) and write handling code to its onclick
server side event.
that is the preferred asp.net technique.

if however you wish to still use the old ways then remove all the
runat=server and you should have a form which you can do you own validation
/ submission. However keep in mind that you will not be able to use
webcontrol will rather be limited to using html input controls. In
otherwords you will just be doing asp programming not asp.net.

I would personally recommend that you use asp.net technique which is a lot
easier.
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"TJS" <no****@here.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
how do I get "onSubmit" to work in .net ?

<Form id="Form1" name="Form1" method="post" onSubmit="return
validateStandard(this, 'error');" runat="server">

Nov 18 '05 #2
TJS
why won't this activate the clientside script ?

<html>
<head>
<script language="javascript">
<!--
function ClientValidate(e,s){
alert("hello");
}
//-->
</script>
</head>
<body >
<form name="Form1" method="post" id="Form1" runat="server">
Password:
<br>
<asp:TextBox id="password" columns="17" width="100px" textmode="password"
runat="server" />
<asp:CustomValidator id="valCustom" runat="server"
ControlToValidate="password"
ClientValidationFunction="ClientValidate"
</asp:CustomValidator>
<asp:ImageButton id="SigninBtn" ImageUrl="~/images/signin.gif"
runat="server" />
</form>
</body>
</html>

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:e8****************@TK2MSFTNGP15.phx.gbl...
depends on how you want to do it.
right now you form is marked as run at server which means you will have to
rely on other controls to initiate a postback.

what you are using is a bog standard asp technique which is not normally
used with asp.net

in asp.net you have 5 validator objects from custom validtor (to implement
your own validtion on a particular control etc. or things like Required
Field Validation, compare validator, range validatior and regular
expressions validator. You have a validation summary object to display a
list of errors or display them in tabular format. with your form as it
stands right now you will have use add a Button or a ImageButton or a
Linkbutton (which are webcontrols) and write handling code to its onclick
server side event.
that is the preferred asp.net technique.

if however you wish to still use the old ways then remove all the
runat=server and you should have a form which you can do you own validation / submission. However keep in mind that you will not be able to use
webcontrol will rather be limited to using html input controls. In
otherwords you will just be doing asp programming not asp.net.

I would personally recommend that you use asp.net technique which is a lot
easier.
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"TJS" <no****@here.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
how do I get "onSubmit" to work in .net ?

<Form id="Form1" name="Form1" method="post" onSubmit="return
validateStandard(this, 'error');" runat="server">


Nov 18 '05 #3
maybe because of the arguments you are using. there is a very specific way
you implement client validation

i have used something like this

if(!Page.IsClientScriptBlockRegistered(clientValid ation))
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=javascript>\n");
sb.Append("function ClientValidation(oSrc, args)\n");
sb.Append("{\n");
sb.Append("\targs.IsValid = document.RegForm.chkAgree.checked\n");
sb.Append("}\n");
sb.Append("</script>");

Page.RegisterClientScriptBlock(clientValidation, sb.ToString());
}

this was from code behind file.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"TJS" <no****@here.com> wrote in message
news:OB**************@tk2msftngp13.phx.gbl...
why won't this activate the clientside script ?

<html>
<head>
<script language="javascript">
<!--
function ClientValidate(e,s){
alert("hello");
}
//-->
</script>
</head>
<body >
<form name="Form1" method="post" id="Form1" runat="server">
Password:
<br>
<asp:TextBox id="password" columns="17" width="100px" textmode="password" runat="server" />
<asp:CustomValidator id="valCustom" runat="server"
ControlToValidate="password"
ClientValidationFunction="ClientValidate"
</asp:CustomValidator>
<asp:ImageButton id="SigninBtn" ImageUrl="~/images/signin.gif"
runat="server" />
</form>
</body>
</html>

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:e8****************@TK2MSFTNGP15.phx.gbl...
depends on how you want to do it.
right now you form is marked as run at server which means you will have to rely on other controls to initiate a postback.

what you are using is a bog standard asp technique which is not normally
used with asp.net

in asp.net you have 5 validator objects from custom validtor (to implement your own validtion on a particular control etc. or things like Required
Field Validation, compare validator, range validatior and regular
expressions validator. You have a validation summary object to display a
list of errors or display them in tabular format. with your form as it
stands right now you will have use add a Button or a ImageButton or a
Linkbutton (which are webcontrols) and write handling code to its onclick server side event.
that is the preferred asp.net technique.

if however you wish to still use the old ways then remove all the
runat=server and you should have a form which you can do you own

validation
/ submission. However keep in mind that you will not be able to use
webcontrol will rather be limited to using html input controls. In
otherwords you will just be doing asp programming not asp.net.

I would personally recommend that you use asp.net technique which is a lot easier.
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"TJS" <no****@here.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
how do I get "onSubmit" to work in .net ?

<Form id="Form1" name="Form1" method="post" onSubmit="return
validateStandard(this, 'error');" runat="server">



Nov 18 '05 #4
have a read of this articles
http://aspnet.4guysfromrolla.com/articles/073102-1.aspx

http://msdn.microsoft.com/library/de...omfunction.asp

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"TJS" <no****@here.com> wrote in message
news:OB**************@tk2msftngp13.phx.gbl...
why won't this activate the clientside script ?

<html>
<head>
<script language="javascript">
<!--
function ClientValidate(e,s){
alert("hello");
}
//-->
</script>
</head>
<body >
<form name="Form1" method="post" id="Form1" runat="server">
Password:
<br>
<asp:TextBox id="password" columns="17" width="100px" textmode="password" runat="server" />
<asp:CustomValidator id="valCustom" runat="server"
ControlToValidate="password"
ClientValidationFunction="ClientValidate"
</asp:CustomValidator>
<asp:ImageButton id="SigninBtn" ImageUrl="~/images/signin.gif"
runat="server" />
</form>
</body>
</html>

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:e8****************@TK2MSFTNGP15.phx.gbl...
depends on how you want to do it.
right now you form is marked as run at server which means you will have to rely on other controls to initiate a postback.

what you are using is a bog standard asp technique which is not normally
used with asp.net

in asp.net you have 5 validator objects from custom validtor (to implement your own validtion on a particular control etc. or things like Required
Field Validation, compare validator, range validatior and regular
expressions validator. You have a validation summary object to display a
list of errors or display them in tabular format. with your form as it
stands right now you will have use add a Button or a ImageButton or a
Linkbutton (which are webcontrols) and write handling code to its onclick server side event.
that is the preferred asp.net technique.

if however you wish to still use the old ways then remove all the
runat=server and you should have a form which you can do you own

validation
/ submission. However keep in mind that you will not be able to use
webcontrol will rather be limited to using html input controls. In
otherwords you will just be doing asp programming not asp.net.

I would personally recommend that you use asp.net technique which is a lot easier.
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"TJS" <no****@here.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
how do I get "onSubmit" to work in .net ?

<Form id="Form1" name="Form1" method="post" onSubmit="return
validateStandard(this, 'error');" runat="server">



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Zeebra3 | last post: by
2 posts views Thread by Niclas Lindblom | last post: by
1 post views Thread by MattC | last post: by
27 posts views Thread by Chris | last post: by
3 posts views Thread by Papanii | last post: by
7 posts views Thread by mc | last post: by

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.