Working with Cognos, I'm currently tackling the challenge of capturing the enter key to validate user input before submitting the prompt.
If you're not familiar with Cognos, that's okay - any insights on my code are welcome :) This tool is primarily designed for creating business reports through a drag-and-drop interface.
On my Cognos prompt page, I've placed a Text Box Prompt and specified a minimum of 3 characters for user input. Enclosed within an HTML div tag, here's how it looks:
<div onKeyDown="return keyMon(event)"> Cognos Text Box </div>
Additionally, I've included another HTML Item housing the keyMon()
function which handles key events:
<script>
function keyMon(e3)
{
var key = e3 || window.event;
if(key.keyCode == 13){
var fW = (typeof getFormWarpRequest == "function" ?
getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) {
fW = ( formWarpRequest_THIS_ ?
formWarpRequest_THIS_ : formWarpRequest_NS_ );
}
var custValue = fW._textEditBoxCustomerPrompt;
if(custValue.value.length > 0){
if(custValue.value.length >= 3){
promptAction('next'); //Proceed to next step
}else{
alert("Please enter a search value that is 3 or more characters long.");
return false;
}
}
}
}
</script>
While this implementation functions smoothly in Internet Explorer, trouble arises when using Firefox. Upon hitting Enter, the alert momentarily displays then vanishes, allowing the process to continue. It seems that the line "return false;" isn't effectively stopping the action.
Any assistance on resolving this issue would be greatly appreciated.