cancel
Showing results for 
Search instead for 
Did you mean: 

Skiping lines of code

Former Member
0 Kudos

Hi,

I want to skip some code without using <b>if case</b>, when certain condition meets,

I also want to use client side validations for password retyping using onClientclick, but after completing this it’s again goes to server side processing. Here my question is how to stop calling server BSP after client side validation.

Regards,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

thanz Ravikiran.C for ur reply,

In JavaScript function how to get false return if condition not meet ?

Former Member
0 Kudos

Hi,

This sample code will solve your problem. Have look over it.

<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<head>
<script language="javascript">
function ValidateForm()
{
var txt1,txt2;
txt1 = document.getElementById("if01");
txt2 = document.getElementById("if02");
alert(txt1.value);
alert(txt2.value);
if (txt1.value != txt2.value)
{
 alert("Your passowrds should match");
 return false;
}
else
return true;
}
</script>
</head>
<htmlb:content design="design2003" >
  <htmlb:page title="Test page to check password " >
    <htmlb:form id="form1" >
      <htmlb:textView text   = "Enter PassWord"
                      design = "EMPHASIZED" />
      <htmlb:inputField id   = "if01"
                        type = "string"
                        size = "20" />
      <br>
      <htmlb:textView text   = "Re-enter PassWord"
                      design = "EMPHASIZED" />
      <htmlb:inputField id   = "if02"
                        type = "string"
                        size = "20" />
      <br>
      <htmlb:button id            = "but01"
                    onClick       = "myEvent"
                    design        = "EMPHASIZED"
                    onClientClick = "if(!ValidateForm(this))htmlbevent.cancelSubmit=true;"
                    text          = "Check" />
    </htmlb:form>
  </htmlb:page>
</htmlb:content>

Thanks & Regards,

Ravikiran.

Answers (2)

Answers (2)

Former Member
0 Kudos

ok that really worked, i was looking for this only.

one more doubt please, how to skip code of lines in OnInputProcessing, let say if i got error in any of function module then it should skip entire OnInputProcessing processing.

Regards

athavanraja
Active Contributor
0 Kudos

why not use a if condition to check for success or failure and execute the code.

Regards

Raja

Former Member
0 Kudos

Hi,

You can try and check out with EXIT statement.

Regards,

Ravikiran.

Former Member
0 Kudos

Hi Bhupendra,

You can perform Client Side Validations you can use JavaScript. In your case of validating password, you can go for validating using JavaScript and calling the JavaScript on button Click. See this code:

<htmlb:button id    = "but01"
      onClick       = "Sales Order"
      design        = "EMPHASIZED"
      onClientClick = "if(!ValidateForm(this))htmlbevent.cancelSubmit=true;"
      text          = "Test Button" />

Using this if the entered password is wrong the script checks for it and cancels the server side event.

Regards,

Ravikiran.C