473,287 Members | 2,682 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

JavaScript to Validate the Money Field :-)

Hi I have tried one more javascript Validator Script to Validate the
Money entered in to the TextBox.

<script language='javascript'>
function checkNumber(val,e){
if(window.event){
var strkeyIE = e.keyCode
if(((strkeyIE >= 48) && (strkeyIE <= 57 )) || (strkeyIE == 44) ||
(strkeyIE == 36) ){}
else{
return false;}}
else{
var strkeyCode = e.keyCode
var strCharCode = e.charCode
if(((strCharCode >= 48) && (strCharCode <= 57 )) || (strCharCode ==
44) || (strCharCode==36)|| (strkeyCode==37 )|| (strkeyCode==38) ||
(strkeyCode == 46)||(strkeyCode==8 ) || (strkeyCode ==9 ) ||
(strkeyCode==39) || (strkeyCode ==35) || (strkeyCode ==36) ||
(strkeyCode==9)){}
else{return false;} }
return true;}
function valFuncReg_Money(text,reg){
if(text == null || text == '')return true;
if(reg == null || reg =='')return true;
var regex = new RegExp(reg);var value=text;
var res= (regex.exec(text));
if(res==null){
reg =/^\$?[0-9]+$/;
regex = new RegExp(reg);
res= (regex.exec(text));}
return (res != null && value == res[0]);}
</script>
The above script can be called on "Onkeypress" event of the TextBox as
follows :

"Onkeypress", "javascript:return checkNumber(this,event);"
Please feel free to give Comments and Suggessions and Bugs also :-)

Aug 5 '08 #1
1 6034
Abhishek wrote:
Hi I have tried one more javascript Validator Script to Validate the
Money entered in to the TextBox.
[...]
Try another one, after you got a minimum clue.
The above script can be called on "Onkeypress" event of the TextBox as
follows :

"Onkeypress", "javascript:return checkNumber(this,event);"
Certainly not.

1. There is no `Onkeypress' event. The event is called `keypress', if that.
2. This is not proper/meaningful syntax in any language.
3. Assuming this is supposed to resemble HTML:
<http://jibbering.com/faq/#FAQ4_24>
4. The local `event' property is proprietary, it can be used but needs
to be feature-tested before.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Aug 5 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Sue | last post by:
In this code why is it that when I press the SUBMIT button the focus only goes back to the Numeric field. What do I need to do to correct this problem? Sue <html>
4
by: Madha K | last post by:
I am developing a web application that need to support UTF-8 characters. For client side validations, can javascript be used to handle UTF-8 characters. 1) How javascript can be used to restrict...
4
by: Steph | last post by:
Hello, Can someone tell me the script to use for having a change on the same page when using checkbox function ? For example, i would to check one condition and display dynamically a button...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
1
by: Nigel | last post by:
Hello, I am creating a Perl CGI page with Javascript which I believe has a problem with the javascript. Below is my form which has two submit buttons with two different actions. I am having...
3
by: pragan | last post by:
HI, I need to create an online form with Details such as Name, Address, EMail, Phone, Message, Credit Card Type/Number/Expiry Date. I started this and I was able to create the form and validate...
4
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
3
by: lowslyn | last post by:
hi, can someone please help me with javascript... i have this code that checks a text field when the user overrides the value to blank/space. if it is blank/space, i need to change the value...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.