473,472 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

checking for numeric values..

47 New Member
hi..
i have a text box..where user input their value.
but i want to allow only numeric values not alphabets and blankspaces..
how to do this in asp..

regards
meenu
Aug 17 '06 #1
6 11057
lakshmanmcaj
35 New Member
hi

hi u can do that in using javascript using this script

function Checknum1(obj){

if(obj.value!=="0")
{
//var valid = "0123456789.";
var valid = "0123456789-/() ."

ph=obj.value;

for (var i=0; i < ph.length; i++) {
temp = ph.substring(i, i+1);
//alert ("tmmp is--"+temp+"--");
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters entered.Please enter digits only.");
//obj.value="";

obj.select();
obj.focus();

return false;
}



}

return true;
}
}


use this script in onblur event ok...


regards
laksh
Aug 17 '06 #2
lipsa
35 New Member
hi,
u hv a "IsNumeric" function in ASP.Check for it
Aug 17 '06 #3
lipsa
35 New Member
in addition 2 my previous answer,
there is a "IsNumeric" function in javascript also.u can use either with much ease
Regards,
Lipsa
Aug 17 '06 #4
sashi
1,754 Recognized Expert Top Contributor
Hi guys,

there is an IsNumeric function in VBScript too.. check out the sample code segment.. take care and have a great day ahead.. :)

Expand|Select|Wrap|Line Numbers
  1. <%
  2.   If IsNumeric(Request.Form("txtSomeTextBox") = False Then
  3.     Response.Redirect "../somepage.asp"
  4.   End If
  5. %>
  6.  
Aug 18 '06 #5
SharmaPriyanka
1 New Member
hi..
i have a text box..where user input their value.
but i want to allow only numeric values not alphabets and blankspaces..
how to do this in asp..

regards
meenu



<SCRIPT language="JavaScript">
function abc(t1)
{
var a,i,s
var count=0
var r=""
var chk=0
a=t1.value.length
for(i=0;i<a;i++)
{
s=t1.value.substring(i,i+1)
if(s>="0" && s<="9"){}
else
{
chk=1
alert("Please enter numerics values only.");
t1.focus();
break;
}
}
}
function IEKeyCap()
{
if ((window.event.keyCode < 46) || (window.event.keyCode > 57) || (window.event.keyCode == 47) || (window.event.keyCode == 46) )
{
window.event.keyCode = 0
};
}
</SCRIPT>


and in textbox-----> onKeyPress='IEKeyCap()' onBlur='abc(this)'
Mar 12 '07 #6
rajivtyagi4u
4 New Member
hi..
i have a text box..where user input their value.
but i want to allow only numeric values not alphabets and blankspaces..
how to do this in asp..

regards
meenu
hi
u jsut check the ASCII value of the input character and then validate the user to give the input only numeric values like
u run a loop and set it i=ascii value of 1(whatever the ascci value of 1) to ascii value of 9
then check it ok
Mar 13 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Robert | last post by:
Hi there! I have a problem I can't get rid of... I hope anyone can help me with it! For a room-booking application I need to select available rooms for a given period. First I do the...
5
by: CJM | last post by:
In an application I'm working the user has the opportunity to record the despatching of one or more items with serial numbers. For each item they despatch, they have to chose the serial no that...
3
by: success_ny | last post by:
Does anyone have a code snippet to compare those values so I can sort the array of alpha-numeric values that include both characters and integers in it? I.e., if we have values like 4236 and...
4
by: Gezeala 'Eyah' Bacu\361o II | last post by:
hey guys..need your help on this.. i have a plpgsql function where in i compute numeric values for my php scripts.. my problem is my function just won't round some numbers properly.. what i...
6
by: M.A. Oude Kotte | last post by:
Hi All, I hope this is the correct mailing list for this question. But neither postgresql.org nor google could help me out on this subject. I did find one disturbing topic on the mailing list...
8
by: Brendan | last post by:
There must be an easy way to do this: For classes that contain very simple data tables, I like to do something like this: class Things(Object): def __init__(self, x, y, z): #assert that x,...
11
by: Pieter | last post by:
Hi, I'm having some troubles with my numeric-types in my VB.NET 2005 application, together with a SQL Server 2000. - I first used Single in my application, and Decimal in my database. But a...
7
by: Sheldon | last post by:
Hi, I have the following loop that I think can be written to run faster in Numeric. I am currently using Numeric. range_va = main.xsize= 600 main.ysize= 600 #msgva is an (600x600) Numeric...
3
by: w.m.gardella.sambeth | last post by:
Hi all, I am more or less new to Python, and currently am making my first "serious" program. The application is a Clinical History manager (for my wife) which stores its data on a sqlite database....
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.