Solved

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

Posted on 2004-10-22
184 Views
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.

Thanks
Naveen
0
Question by:naveenkhosla
    3 Comments
     
    LVL 21

    Expert Comment

    by:MogalManic
    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)">
    ...
    </form>

    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
    0
     

    Author Comment

    by:naveenkhosla
    Thanks a lot

    The solution worked for me.
    0
     

    Accepted Solution

    by:
    maby you should accept the answer then :)
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    This is an explanation of a simple data model to help parse a JSON feed
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    875 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now