By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,223 Members | 1,371 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,223 IT Pros & Developers. It's quick & easy.

clientside javascript validation for form

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.