Skip to Content
author's profile photo Former Member
Former Member

Error message code on BSP Page

Hi experts,

I have one code like this :

<%

IF co_model->firstname CA '+-=<>()'.

%>

<script language = "Javascript">

alert ("First name is not correct")

</script>

<%ENDIF.%>

It is showing only warning message and allowing to save the data of BSP Page when press Save Button.

In need to convert this alert (Warning) message into Error Message,

Please help, it is urgent,

Thanks in advance,

Study SAP

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 31, 2007 at 10:34 AM

    Hi,

    This is correct as the variable <b>co_model->firstname</b> is still not changed with the value you entered on the screen. It will change after one server trip...but the code is checking this before the server trip on the client side....

    To avoid this try using the indexOf function of JavaScript....which basically check the occurence of a particular string in another string.

    I will try and attach a sample code....

    Hope this helps.

    <b><i>Do reward each useful answer..!</i></b>

    Thanks,

    Tatvagna.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Thanks Tatvagna,

      This code is working same as last code, the problem remains the same.

      When I am changing the value, it is not considering changed value on screen.

      It is considering old value.

      Thanks in advance,

      Study SAP

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2007 at 01:11 PM

    Hi,

    Try using this inside a function or something.....

    eg, if you want this onClick of a button,

              <htmlb:button id            = "Save"
                            text          = "Save"
                            disabled      = "FALSE"
                            design        = "EMPHASIZED"
                            onClick       = "onInputProcessing"
                            onClientClick = "if(!checkName()){htmlbevent.cancelSubmit=true;}" />
    
    
    
    <script language = "Javascript">
    function checkName(){
    <%
    IF co_model->firstname CA '+-=<>()'.
    %>
    
    alert ("First name is not correct")
    return false;
    <%ELSE.%>
    return true;
    <%ENDIF.%>
    }
    </script>

    But also, for the record, it is not advisable to combine javascript and ABAP....

    so you can also use the string.indexOf() function in javascript to check if the name contains special characters that you mentioned.....

    Hope this helps.

    <b><i>Do reward each useful answer..!</i></b>

    Thanks,

    Tatvagna.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Tatvagna,

      This code is working fine, but there is one problem, when I am clicking on Save Button, it is considering my earlier value for checking the name.

      It does not consider the current value, when i changed the previous value on this page.

      Please help,

      Thanks in advance,

      Study SAP

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.