COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: dipstm on 21 May 2008 01:52:28 AM

Title: Regarding Texbox validations using Javascript
Post by: dipstm on 21 May 2008 01:52:28 AM

Hi,

I have textbox prompts and value prompts in my report. I have used Javascript in textbox prompt for validating the special characters entered in the textbox prompt and Javascript in value prompt for hiding the prompt parameter name of the value prompt. But this script works fine only for the first time and whenever I run the report for next time, the Javascripts doesnt work and validations for textbox prompt doesnot work.Also for value prompt it displays the prompt parameter name.
I have used the following javascript:
Textbox prompt :
<script language="javascript">

function TextboxSplChar()
{

var iChars = "!@#$%^&*+=;,.{}|:<>?";

  for (var i = 0; i < document.forms[0].elements["_textEditBoxCatalogNo"].value.length; i++) {
     if (iChars.indexOf(document.forms[0].elements["_textEditBoxCatalogNo11111"].value.charAt(i)) != -1) {
     alert ("You have entered special characters. \nThese are not allowed.\n Please remove them and try again.");
     return false;
     }
  }
}

document.forms[0].elements["_textEditBoxCatalogNo11111"].onchange=TextboxSplChar;

</script>




Value prompt:
<script>

mylist = document.forms[0].elements["_oLstChoicesPLINE"];
mylist.remove(0);
mylist.onchange();

</script>


Any help will be appreciated.

Regards,
Dipstm
Title: Re: Regarding Texbox validations using Javascript
Post by: kattaviz on 21 May 2008 08:11:05 AM
Hi,

Try to use the following insted of "document.forms[0]". I know it does the same thing but
i saw some weird things happening.

document.getElementById('formWarpRequestRS').

HTH
Title: Re: Regarding Texbox validations using Javascript
Post by: dipstm on 26 May 2008 02:06:42 AM
Hi,
I tried using as u mentioned but its not working. I guess there is something wrong using Javascripts in Cognos 8.3

Any suggestions .....

Regards,
dipstsm
Title: Re: Regarding Texbox validations using Javascript
Post by: kattaviz on 27 May 2008 10:32:46 AM
Hi,
I have used the following script to remove the parameter name from the listbox values.

document.getElementById('formWarpRequestRS')._oLstChoicesXXX.options[0]=null;

where XXX is the name of the value prompt.

HTH
Satish