•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 363,440 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,205 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 849 | Replies: 4
![]() |
•
•
Join Date: Mar 2008
Location: Madrid - Spain
Posts: 20
Reputation:
Rep Power: 1
Solved Threads: 2
•
•
Join Date: Mar 2008
Location: Madrid - Spain
Posts: 20
Reputation:
Rep Power: 1
Solved Threads: 2
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.
<!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.
•
•
Join Date: Apr 2005
Location: New York state
Posts: 438
Reputation:
Rep Power: 5
Solved Threads: 61
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 z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
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 / 2003)
- 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


Linear Mode