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

Form Validation + Stop processing

Hello Friends,

I have one form, with some input fields, I am doing JavaScript validation ( is there any other option ?), forexample if any mandatory input field left empty, on clicking submit, it will show an aler(.....) to user?

here is the script I am using!

function validate()

{

x=document.Create

field=x.field.value

if (field.length<1)

{

alert("Please enter .....")

submitOK="False"

}

}

Now the problem is that, when user click okey on this alert, the processing does not stop and it proceed.

Usually ' submitOK="False" ' is used to stop the processing, but here its not working ??

I have one button.

<htmlb:button id = "createBP"

onClick = "create"

text = "Submit" />

I have tried createBP = 'false', but did not work ??

Any idea, how I can stop the processing!!

Marek

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 09, 2004 at 11:22 PM

    The built in doValidate logic on date and time input fields does what you are asking. Not sure how it works but you may be able to debug it. SAP has found a way to do it.

    However if you are on screen with multiple tabs, and the field being validated is not currently visible the processing logic gets kicked off. So be aware of that.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2004 at 06:49 AM

    hai marek,

    do in this way,

    function validate()

    {

    if (document.fromname.inputfieldname.value=='')

    {

    alert("message");

    document.fromname.inputfieldname.setfocus;

    return true;

    }

    }

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2004 at 01:08 PM

    Hi Marek,

    You can avoid navigation by using the statement :

    <b>htmlbEvent.cancelSubmit = "true"</b> in your JavaScript function.

    The problem with your code is that SUBMIT request raised when the button is clicked is not cancelled. So, the program navigates to the next page after the ALERT statement.

    <b>function(){

    if error{

    alert();

    htmlbEvent.cancelSubmit = "true";

    }

    }</b>

    Add a comment
    10|10000 characters needed characters exceeded

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.