COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: suhas_bhat on 09 Jun 2011 02:22:44 AM

Title: Restricting entries for Text Box Prompt
Post by: suhas_bhat on 09 Jun 2011 02:22:44 AM
Hi all,
   Is it possible to restrict entries in a text box prompt.
I want users to be able to enter digits higher than 2 only.
There is a property to set text box prompt to accept only numbers but how do we restrict them to a lower limit.
If there is any way to achieve this through javascript pls share.
Thanks.
Title: Re: Restricting entries for Text Box Prompt
Post by: Arpitagrawal9 on 15 Jun 2011 02:19:38 AM
Hi,

You can use the sample code for Adding a javascript alert
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Number validation example</title>
  <meta name="generator" content="editplus" />
  <meta name="author" content="" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <script type="text/javascript">
  function goReturn() {
     getEvent=event.keyCode;
    if(getEvent>=51 && getEvent<=57)
    {
    return true;
    }
     else{
     alert("You did not enter a Valid number!!Please enter a valid number higher than 2!!");
    return false;
    }
   }
  </script>
</head>

<body>
<form name="myform" id="myform">
   Enter any Value: (Numbers only!!)<input type="text" .. onkeypress="return goReturn()">
</form>
</body>
</html>

Hope this helps:)