Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


ASP.Net - Both server and client validations on a single buton click

Posted on 2004-10-22
Medium Priority
Last Modified: 2010-04-17
Hi All,

In ASP.NET, I have a Submit Button. On the click of the button, I need to add a Javascript confirmation if a particular condition matches. The application should first do the required field validations, then check for the condition and then promt a confirmation to submit the form.
The submit should happen depending on the confirmation of the user.
Kindly help me out.
I tried this by includitn the following line in Page_Load()

this.btnSave.Attributes["onclick"] = "return fnConfirm(this);";

By doing this, the javascript confirmation works, but no other validations are fired.

Question by:naveenkhosla
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 21

Expert Comment

ID: 12378995
Put the validation on the form.onSubmit event:
this.MyForm["onSubmit"]="return fnConfirm(this);";

OR you can regester for the event in the HTML:

<form name='MyForm'  action=...  onSubmit="return fnConfirm(this)">

The fnConfirm function will take the form as a parameter and check each field for validity.  If a field is invalid, display a message and return FALSE.

If All are valid, then return true

Author Comment

ID: 12379185
Thanks a lot

The solution worked for me.

Accepted Solution

sirono earned 1000 total points
ID: 12380383
maby you should accept the answer then :)

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Six Sigma Control Plans

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question