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
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.
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