JS Validation, Math Problem in JS Validation |
JS Validation, Math Problem in JS Validation |
Ollie |
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 "<" You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", 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 "<" does NOT function as a Math Operator. This post has been edited by Ollie: Mar 2 2011, 01:27 PM |
Christian J |
Mar 2 2011, 02:05 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
|
pandy |
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 |
Lo-Fi Version | Time is now: 18th April 2024 - 09:21 PM |