Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
IBM Cognos 8 Report Studio Cookbook

You're reading from   IBM Cognos 8 Report Studio Cookbook Over 80 great recipes for taking control of Cognos 8 Report Studio

Arrow left icon
Product type Paperback
Published in Jun 2010
Publisher Packt
ISBN-13 9781849680349
Length 272 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Abhishek Sanghani Abhishek Sanghani
Author Profile Icon Abhishek Sanghani
Abhishek Sanghani
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

IBM Cognos 8 Report Studio Cookbook
Credits
About the Author
About the Reviewers
Preface
1. Report Authoring Basic Concepts FREE CHAPTER 2. Advanced Report Authoring 3. Tips and Tricks: JavaScripts 4. Tips and Tricks: Report Page 5. XML Editing 6. Writing Printable Reports 7. Working with Dimensional Models 8. Macros 9. Using Report Studio Better 10. Some More Useful Recipes 11. Best Practices Recommendations and References Index

Validating textbox prompts


There is a report with a textbox prompt. Users are expected to enter a phone number in (nnn)nnn-nnnn format in that prompt.

In this recipe, we will write a code to validate the value entered by the user and submit the report only if the value entered is in specified format.

Getting ready

Pick any report and add a textbox prompt to it. We will add a JavaScript to validate that textbox.

How to do it...

  1. Wrap the textbox prompt within a SPAN in the same way as we did in prior recipes.

  2. Add the following script to the page footer:

    <script>
    function ValidatePage()
    {
    var theSpan = document.getElementById("A1");
    var a = theSpan.getElementsByTagName("input"); /* this captures the textbox */
    for( var i = a.length-1; i >= 0; i-- )
    {
    var link = a[i];
    if( link.id.match(/PRMT_TB_/))
              {phoneRegex = /^\(\d{3}\) \d{3}-\d{4}$/; /* This is regular expression to allow only the strings in (nnn) nnn-nnnn format */
                if( !link.value.match( phoneRegex ) ) {
          ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime