| | |
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 |
acid2 ajax ajaxcode ajaxhelp animate array automatically beta box bug calendar cart checkbox child class codes column cookies createrange() css cursor date debugger decimal design dom download dropdown editor element enter error explorer file firefox focus forms frameworks getselection google gwt html htmlform ie8 iframe images index internet java javascript jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math menu microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent php player post problem programming progressbar prototype redirect regex runtime safari scale scriptlets search select session shopping size sql text textarea toggle variables w3c web website window windowofwords windowsxp wysiwyg \n






