| | |
decimal (10,2) limit
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
From your message, I conclude that your problem is that Javascript does not understand that for you, "10,2" equals "10.2".
Here I wrote a sample html, but the important part is the javascript function that checks the value.
Hope this is what you need.
Here I wrote a sample html, but the important part is the javascript function that checks the value.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<!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> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>No title</title> <script type="text/javascript" language="javascript"> function curcheck(curf,maxval) { textcur = curf.value.toString(); textcur += ''; x = textcur.split(','); textcur = x[0]+'.'+x[1]; if(Number(textcur) > maxval) { say('result',false); return } say('result',true); } function say(were,val) { text = ( val ) ? "Valid value entered" : "Invalid value entered" ; eval("document.getElementById('"+were+"').innerHTML = text"); } </script> </head> <body> <form id="myform" action="" > <input type="text" size="4" id="currency" onchange="curcheck(this,10.2);" /> <p id="result"> </p> </form> </body> </html>
Hope this is what you need.
You keep going, have a Nice day!
Henry.
Before printing this message, make sure is necessary.
Henry.
Before printing this message, make sure is necessary.
You would test the form field with a regex like this.
(10, 2) in database means 10 numbers, 2 decimal places. so 12345678.90 is valid.
(10, 2) in database means 10 numbers, 2 decimal places. so 12345678.90 is valid.
javascript Syntax (Toggle Plain Text)
var testRegEx = /[0-9]{1,8}\.?[0-9]{0,2}/ var isValidNumber = form.formField.value.match(testRegEx);
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
![]() |
Similar Threads
- Limit Text box input (VB.NET)
- limit input only two decimal (Java)
- please help with insertion sort (C++)
- 130gb hd limit, upto date win2000 and bios (should have solve it but did not) (Windows NT / 2000 / XP)
- not-a-virusadware (Viruses, Spyware and other Nasties)
- Help With Data-type Declaration Symbols (Pascal and Delphi)
- have a try if you are interested in... (C++)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Drop Down box AJAX
- Next Thread: unVisible Listbox
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxhelp animate api automatically beta boarder box bug calendar captchaformproblem card checkbox child class column cookies createrange() css cursor dependent disablefirebug dom download dropdown editor element engine error events explorer ext file firehose flash form forms google gwt html htmlform ie8 iframe image() images internet java javascript jawascriptruntimeerror jquery jsf jsfile jump math matrixcaptcha microsoft mimic mp3 mysql object offline onmouseoutdivproblem onreadystatechange parent passing pdf php player post problem progressbar rated rating regex runtime scroll search select session shopping size sql star stars stretch text textarea twitter validation w3c web website window windowofwords windowsxp wysiwyg xml xspf \n






