| | |
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: 497
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 ajaxhelp animate automatically beta box bug calendar captcha cart checkbox child class column cookies createrange() css cursor decimal design dom download dropdown editor element engine enter error events explorer file focus form forms frameworks google gwt html htmlform ie8 iframe image() images index internet java javascript jawascriptruntimeerror jquery jsf jsfile jump listbox math matrixcaptcha menu microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent pdf php player post problem progressbar prototype rated rating regex runtime scale scroll search select session shopping size sql star starrating stars text textarea validation w3c web website window windowofwords windowsxp wysiwyg xml \n





