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

if (isNaN(form1.paid.value)) {
   alert ("Syntax is not right.");
   return false;		
}
return true;

Try if(!form1.paid.value.match(/^(\d+|\d*\.(\d+))$/)) .

No it still returns true for dot.

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.

<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>

I solved with checking all the characters bit by bit in textbox, if they are numeric or not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.