Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Showing Error Using Java Script

Showing Error Using Java Script

Scheduled Pinned Locked Moved ASP.NET
helpjavajavascriptcsstools
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ais07
    wrote on last edited by
    #1

    Hi There, I had written funtion in js file to check two textbox values.Funtion is if textbox1 value is less than textbox 2 value then it should throw an error. I am Calling this funtion on click of save button.There is no problem in executing this funtion.But my problem is that when I Click on Save button this funtion gets executed but after the error occure then also code written on button for save button get executed.Now I want to restrict this code from executing after error occure in js funtion.Is it possible. If anybody knows please help. Thanks

    P R 2 Replies Last reply
    0
    • A ais07

      Hi There, I had written funtion in js file to check two textbox values.Funtion is if textbox1 value is less than textbox 2 value then it should throw an error. I am Calling this funtion on click of save button.There is no problem in executing this funtion.But my problem is that when I Click on Save button this funtion gets executed but after the error occure then also code written on button for save button get executed.Now I want to restrict this code from executing after error occure in js funtion.Is it possible. If anybody knows please help. Thanks

      P Offline
      P Offline
      Perspx
      wrote on last edited by
      #2

      You may want to post some of your code here to help explain your problem and allow for someone to help you out more easily. Regards, --Perspx

      "A refund for defective software might be nice, except it would bankrupt the entire software industry in the first year."
      -Andrew Tanenbaum
      "Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer."
      -Fred Brooks

      1 Reply Last reply
      0
      • A ais07

        Hi There, I had written funtion in js file to check two textbox values.Funtion is if textbox1 value is less than textbox 2 value then it should throw an error. I am Calling this funtion on click of save button.There is no problem in executing this funtion.But my problem is that when I Click on Save button this funtion gets executed but after the error occure then also code written on button for save button get executed.Now I want to restrict this code from executing after error occure in js funtion.Is it possible. If anybody knows please help. Thanks

        R Offline
        R Offline
        Ranjit Viswakumar
        wrote on last edited by
        #3

        Try something like this for your Javascript-

        function validateValues(theForm) {
        var error = "";
        if (theForm.textbox1 < theForm.textbox2) {
        reason = "-textbox1 must be greater than textbox2."
        }
        if (reason != "") {
        alert("Some fields need correction:\n" + reason);
        return false;
        }
        return true;
        }

        ...and the form should contain-

        <form method=POST action=action.aspx name=Demo onSubmit='return validateValues(this)'>

        Good luck!

        Ranjit Viswakumar Professional Services Specialist http://hostmysite.com/?utm\_source=bb

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups