The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> JS Validation, Math Problem in JS Validation
Ollie
post Mar 2 2011, 01:26 PM
Post #1





Group: Members
Posts: 1
Joined: 2-March 11
Member No.: 14,028



Does anyone know of a work around for the following problem?

http://mdwvo.com/oysters/contactform.php
Validation Output: 1 Error
Line 120, Column 43: character "<" is the first character of a delimiter but occurred as data
while(num.length - num.indexOf(".") - 1 < ✉
This message may appear in several cases:

You tried to include the "<" character in your page: you should escape it as "&lt;"
You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&amp;", which is always safe.
Another possibility is that you forgot to close quotes in a previous tag.

Line 120, Column 43: StartTag: invalid element name
while(num.length - num.indexOf(".") - 1 <

Here is the entire JS:

<script language="javascript" type="text/javascript">
var RATE=.06;/* percent rate for shipping */
function addTotals() {
with (document.forms["f1"])
{
var totalResult = Number( size.value ) * Number( qty.value );
var _total = roundTo(totalResult,2);
sub_total.value = _total;
var _tax = roundTo((totalResult * RATE),2);
tax.value = _tax;
total.value = roundTo(parseFloat(_total) + parseFloat(_tax),2);
}
}


function roundTo(num,pow){
if( isNaN( num ) )
{
num = 0;
}

num *= Math.pow(10,pow);
num = (Math.round(num)/Math.pow(10,pow))+ "" ;
if(num.indexOf(".") == -1)
num += "." ;
while(num.length - num.indexOf(".") - 1 <
pow)
num += "0" ;

return num;
}

</script>

The problem is that "&lt;" does NOT function as a Math Operator.

This post has been edited by Ollie: Mar 2 2011, 01:27 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 2 2011, 02:05 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,648
Joined: 10-August 06
Member No.: 7



See https://developer.mozilla.org/en/Properly_U...XHTML_Documents
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 2 2011, 02:08 PM
Post #3


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Use an external script file (the better choice) or use the CDATA hack.

http://www.w3.org/TR/xhtml1/#h-4.8
http://www.doxdesk.com/personal/posts/wd/20010911-cdata.html

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 15th April 2024 - 10:32 PM