SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    420
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    custom error message when function not true

    i would like to edit the error message that displays when an argument is 'invalid' on my form.

    at the moment if the journey is ok then the 'book now' button becomes visible and the forms is ready.

    The function outputs the following response
    The Cost of the Trip is X.XX

    if the journey is NOT ok then it currently displays a specific error taken from an attribute in my database. for example:
    Invalid Job Charge "Driver Gets"

    i am quite certain that the function that produces these responses is this:

    Code:
    var ProcessQuotation = function(transport)
    {
        var response = transport.responseText;
        Validate(4, true);
        <% if (!!Session("SuppressChargesBeforeBooked")) { %>
        if (response.indexOf("Error") < 0) response = "Ready to Book";
        <% } %>
        document.getElementById("Quote").innerHTML = response;
        <% if (Session("User").IsNewUser) { %>
        document.getElementById("BookNow").style.visibility = "visible";
        <% } %>
    }
    If i wanted to customize the ERROR (false) response to read 'this job is invalid, please call the office' (for example), how could i do that in the above.

    thanks

  2. #2
    SitePoint Evangelist TommiChi's Avatar
    Join Date
    Oct 2008
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You would need to encapsulate the code in your function within a try/catch expression. In the catch area, you can invoke an alert to notify the user of the error that occurred.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •