Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2009, 10:50 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Question Valid Javascript to get working in xslt

Hi,
I found this code that allows anly numeric char, the problem i have is that the xslt file does not like the script:

<SCRIPT TYPE='text/javascript'>
function IsNumeric(sText)
{
var ValidChars = "0123456789.";
var IsNumber=true;
var Char;

for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;

}
</SCRIPT>

Please Assist!
 
Old January 6th, 2009, 11:26 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

What is the relationship of this script to your XSLT (did it embed it, invoke it, generate it?)

And what makes you think it didn't like it? Was there an error message?

Note that any text containing "<" or "&" must be properly escaped if included in an XML file.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old January 7th, 2009, 05:05 AM
Friend of Wrox
 
Join Date: Jan 2007
Posts: 115
Thanks: 2
Thanked 0 Times in 0 Posts
Question

Hi, Thank You.

I have dev tool that uses asp + xslt page.
On the dev tool I have objects, text box with poperties & events i can use.
The problem i have is that I only want a numeric value in a textbox of datatype text. Don't want to change it to numeric as it rounds/trims the value when wanting to do a calulcation.
So in the xslt file i want to add a javascript function that i can use on the onkeyevent of the textbox not to allow numeric characters.
Still struggling though!
The function between the <![CDATA[ is like it is filtered out (font light grey) and can't use the function.
<SCRIPT TYPE='text/javascript'>
<![CDATA[
function IsNumeric(sText)
{
var ValidChars = "0123456789.";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;
}
]]>
</SCRIPT>





Similar Threads
Thread Thread Starter Forum Replies Last Post
class names in xslt not working chobo XSLT 2 January 13th, 2008 02:43 AM
Working JavaScript Regex vinaura Javascript How-To 0 August 16th, 2007 01:06 PM
Javascript Not working sohrabus ASP.NET 2.0 Professional 4 May 5th, 2007 12:42 PM
diff b/w javascript validation & server side valid ashu VS.NET 2002/2003 1 March 27th, 2007 09:30 AM
working with existing xml using xslt bv_arvind XSLT 1 March 12th, 2007 01:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.