| | |
Validation for (.) and (,)
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 496
Reputation:
Solved Threads: 0
Hi,
Code below returns true for (.). It should return false like it returns false for (,). Is there any other way to check (.) and (,). I simply want validate money.
Thanks
Code below returns true for (.). It should return false like it returns false for (,). Is there any other way to check (.) and (,). I simply want validate money.
Thanks
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
if (isNaN(form1.paid.value)) { alert ("Syntax is not right."); return false; } return true;
Try
if(!form1.paid.value.match(/^(\d+|\d*\.(\d+))$/)) . Chaos
Lost Souls: text based RPG
MUDseek: MUD gaming search
Lost Souls: text based RPG
MUDseek: MUD gaming search
The pattern I posted will only return true for a dot if it has one or more numeric digits after it. Make sure you're actually trying what I posted.
Chaos
Lost Souls: text based RPG
MUDseek: MUD gaming search
Lost Souls: text based RPG
MUDseek: MUD gaming search
javascript Syntax (Toggle Plain Text)
<script type="text/javascript"> <!--Begin Hiding function validateForm(form) { form = (form.paid.value.indexOf('.') == -1 || form.paid.value.indexOf(',') > 0 ) ? alert('\nInvalid entry!\nPlease try again...') : alert('Thank you!'); } /* This will validate your form if the user include any of this (',') or exclude one of this ('.') he/she wil be alerted with invalid entry! Hope this one helps you...*///Enjoy--> // Done Hiding --> </script>
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
![]() |
Similar Threads
- W3C Validation (HTML and CSS)
- .net validation/javascript conflict (ASP.NET)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Using onMouseOver in CSS??????
- Next Thread: how to use escape and unescape
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser bug calendar captchaformproblem cart close codes column cookies css date debugger decimal dependent design disablefirebug dom download element embed engine enter error events ext file firefox focus form frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 iframe index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp libcurl listbox maps masterpage media menu microsoft mimic mp4 onmouseoutdivproblem onmouseover paypal pdf php player position post problem programming prototype redirect regex safari scale scriptlets scroll search security select software sql text textarea toggle unicode variables w3c website window windowofwords windowsxp





