Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > ASP and ASP.NET
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 05-23-2008, 08:33 AM
  #1
bl4ck1c3
Fighter (Level 4)
 
bl4ck1c3's Avatar
 
Join Date: Apr 2008
Location: Portugal
Posts: 34
iTrader: (0)
bl4ck1c3 is an unknown quantity at this point
Arrow ASP.net and Javascript - Validation

Hi there!!

I'm new at ASP (2 weeks old LoL), and I've created field validations (javascript) on a form, and on the submit button I did ...
HTML Code:
onclick="validateForms();"
so I call my function to validate the fields but if even a field fails to validate for example not valid email, the form is still submitted to the .aspx file ... perhaps this is resolved on the javascript part but I believe you asp ppl know what can I do...

Thanks for your time!
__________________
" On my way DOWN to the TOP !! "
bl4ck1c3 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 02-05-2009, 04:58 PM
  #2
kulrom
Fighter (Level 4)
 
kulrom's Avatar
 
Join Date: Jan 2007
Posts: 37
iTrader: (0)
kulrom is an unknown quantity at this point
Please post the JS code so we can provide guidance how to solve it.
Meanwhile try to assign the validateForms function to the form's onsubmit event handler.
Code:
<form onsubmit="return validateForms();" action="submit.aspx">

Last edited by kulrom : 02-10-2009 at 01:33 AM.
kulrom is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 02-09-2009, 07:27 AM
  #3
afterburn
Can't say much here
 
afterburn's Avatar
 
Join Date: May 2004
Posts: 2,851
iTrader: (0)
afterburn will become famous soon enough
kulrom, .net doesn't work like that. It would be a bad idea to set the action of the form statically. also attributes when it is a control aren't like that.

instead you would have to btnSubmit.Attributes.Add("onclick","return ValidateForm();"
__________________
ASP.net nice bits
Code Smith rocking tool for Code Generation in any language (Written in .net)
Red Gate SQL tools for DBA
Blog Personal blog
.afterburn
afterburn is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 02-10-2009, 01:32 AM
  #4
kulrom
Fighter (Level 4)
 
kulrom's Avatar
 
Join Date: Jan 2007
Posts: 37
iTrader: (0)
kulrom is an unknown quantity at this point
Quote:
Originally Posted by afterburn View Post
kulrom, .net doesn't work like that. It would be a bad idea to set the action of the form statically. also attributes when it is a control aren't like that.

instead you would have to btnSubmit.Attributes.Add("onclick","return ValidateForm();"
ha ...
Actually this has nothing to do with the .NET. You only demonstrated how to add some client-side code to the btnSubmit server-side control. The only difference is that i suggested him to use (onsubmit attribute of the form object) onsubmit event handler which Fires when a FORM is about to be submitted.
So the final result is the same.

Regards
kulrom is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 02-10-2009, 08:58 AM
  #5
afterburn
Can't say much here
 
afterburn's Avatar
 
Join Date: May 2004
Posts: 2,851
iTrader: (0)
afterburn will become famous soon enough
incorrect it has everything to do with .net as it is in the .net forum. the .net form tag is 99% of the time inside of a master page so you do not access it directly, instead you access the controls on the current page. Otherwise you would have the attribute applied to every page that it uses the masterpage. In .net the model is completely different than you would normally think of it as, I would only do that type of stuff on classic ASP, not .net.

in asp.net pages post back to themselves and events for the button that was clicked. It isn't like asp where you would do if Request.Form("Test") then x
instead the button is wired directly to a delegate of a specific definition. To put it simply the masterpage contains the layout of the site with the form tag; to do as you suggest executes the method on every page that it is used; not a great idea. On pages that don't you still would have to add the attribute to the ASp.net form tag on the fly in code otherwise it is an invalid property in runtime code.
__________________
ASP.net nice bits
Code Smith rocking tool for Code Generation in any language (Written in .net)
Red Gate SQL tools for DBA
Blog Personal blog
.afterburn
afterburn is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 02-10-2009, 10:01 AM
  #6
kulrom
Fighter (Level 4)
 
kulrom's Avatar
 
Join Date: Jan 2007
Posts: 37
iTrader: (0)
kulrom is an unknown quantity at this point
C'mon dude .. re-read his question. Again javascript validation has nothing to do with ASP.NET. If you think that you have explained something new to me then you should know that you haven't. But anyway thanks for the try. It's much appreciated!
kulrom is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 02-10-2009, 03:53 PM
  #7
afterburn
Can't say much here
 
afterburn's Avatar
 
Join Date: May 2004
Posts: 2,851
iTrader: (0)
afterburn will become famous soon enough
kulrom,

do not confuse knowledge with wisdom; i have read it; you have to be able to see the issue and let the OP find a solution that works correctly. Unlike your method which has a none validated page in the public.
__________________
ASP.net nice bits
Code Smith rocking tool for Code Generation in any language (Written in .net)
Red Gate SQL tools for DBA
Blog Personal blog
.afterburn
afterburn is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 02-11-2009, 01:15 AM
  #8
kulrom
Fighter (Level 4)
 
kulrom's Avatar
 
Join Date: Jan 2007
Posts: 37
iTrader: (0)
kulrom is an unknown quantity at this point
It seems that your Posts number lets you behave like this. Posts: 2,742

You have no idea what you are talking about here but anyway you push it. Just it matters that you have the last word right? Ok you made the point i will not post anymore.

Now it's obvious why nobody posts here.

my last post here so don't waste your time to prove anything. Period!
kulrom is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 02-11-2009, 12:13 PM
  #9
afterburn
Can't say much here
 
afterburn's Avatar
 
Join Date: May 2004
Posts: 2,851
iTrader: (0)
afterburn will become famous soon enough
actually my posts have nothing to do with it, i am a moderator here. I have been for over 3 years.

I would suggest you attempt to find an arguement that is valid instead of attacking someone because you beleive you are correct; I am not saying it isn't i was giving him a solution that works correctly with in .net controls. instead of having an unmanaged post which wouldn't work in the first place unless you disable Page validation. Either way you should read up on security during development.

There are more than one way to skin a cat. You are welcome to post, i was giving the user a method to be able to find a solution that works within the framework. It is OOP and breaking it hurts performance, security and usablity. I do not see why you are attempting to suggest that I have done anything but point both of you in the right direction.
__________________
ASP.net nice bits
Code Smith rocking tool for Code Generation in any language (Written in .net)
Red Gate SQL tools for DBA
Blog Personal blog
.afterburn
afterburn is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart



 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 06:37 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.