473,326 Members | 2,148 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,326 software developers and data experts.

Problem in JavaScript Help me :(

missshaikh
Hi All Friends,

i have a Problem in JS.
i m working on ASP2.0.
I neet to use JavaScript in my page.
When user enter the String in TextBox the Java Script Prompt
"Enter the Number Only"

Means want to validation for integers.

my code is this
Expand|Select|Wrap|Line Numbers
  1. <script language="Javascript">
  2. function submitcheck()
  3. {
  4.  
  5. center= document.getElementById('<%=txtNumbs.ClientID%>' ).value
  6. valabc = '1'
  7. //document.write(valabc);
  8. csearchtype = valabc
  9. abc = document.getElementById('<%=txtNumbs.ClientID%>' ).value.length
  10.  
  11. if (csearchtype=="phone") 
  12.  {
  13.    if (abc<=4)
  14.       {
  15.        document.PTSEARCH.stext.focus()
  16.        alert ("Please Enter At Least Six Character Phone No")
  17.        return;
  18.        }
  19.  
  20.  for (a = 0; a <abc;a++)    
  21.         {
  22.        if (!((center.charAt(a) >= '0') &&
  23.                (center.charAt(a) <= '9')) )  
  24.         {
  25.                 document.PTSEARCH.stext.focus()
  26.                     alert("Only 0 to 9 are allowed");
  27.           return;
  28.         }
  29.        }
  30.  
  31.  
  32.  }
  33. }
  34.  
and my Html is this
Expand|Select|Wrap|Line Numbers
  1.  
  2. <asp:Button ID="Button1" runat="server" OnClientClick="return submitcheck()" OnClick="Button1_Click" Text="Search" />
Jun 27 '07 #1
2 1248
nateraaaa
663 Expert 512MB
Hi All Friends,

i have a Problem in JS.
i m working on ASP2.0.
I neet to use JavaScript in my page.
When user enter the String in TextBox the Java Script Prompt
"Enter the Number Only"

Means want to validation for integers.

my code is this

<script language="Javascript">
function submitcheck()
{

center= document.getElementById('<%=txtNumbs.ClientID%>' ).value
valabc = '1'
//document.write(valabc);
csearchtype = valabc
abc = document.getElementById('<%=txtNumbs.ClientID%>' ).value.length

if (csearchtype=="phone")
{
if (abc<=4)
{
document.PTSEARCH.stext.focus()
alert ("Please Enter At Least Six Character Phone No")
return;
}

for (a = 0; a <abc;a++)
{
if (!((center.charAt(a) >= '0') &&
(center.charAt(a) <= '9')) )
{
document.PTSEARCH.stext.focus()
alert("Only 0 to 9 are allowed");
return;
}
}


}
}


and my Html is this


<asp:Button ID="Button1" runat="server" OnClientClick="return submitcheck()" OnClick="Button1_Click" Text="Search" />
Try something like this
Expand|Select|Wrap|Line Numbers
  1. function fnIsNumeric(evt)
  2. {
  3. var charCode = (evt.which) ? evt.which : event.keyCode
  4. if (charCode > 31 && (charCode < 48 || charCode > 57))
  5. {
  6. return false;
  7. }
  8. return true;
  9. }
Expand|Select|Wrap|Line Numbers
  1. <asp:textbox id="txtZipCode" onkeypress="return fnIsNumeric(event)" Runat="server"></asp:textbox>
This will not let the user enter anything in the textbox that is not between 0 and 9.

Nathan
Jun 27 '07 #2
Frinavale
9,735 Expert Mod 8TB
Have you seen the .NET article on how to check if a textbox contains a number?

-Frinny
Jun 27 '07 #3

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

Similar topics

7
by: Aaron Prohaska | last post by:
I have just run into a problem where I have a page that posts back to itself to execute code, except when the page does the post back it somehow executes code that is in our home page for the site....
4
by: Federico Bari | last post by:
Good morning all from italy, i have probably a compatibility problem with a html/javascript page. The aim of the code of the file test.htm you find here following (copy the 3 files in the...
1
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function...
4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
1
by: Julius Mong | last post by:
Dear all, according to the ASV3 manual known problem section, to make an <a> execute some Javascript onclick: ...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
0
by: Thomas Due | last post by:
Hello, I am in the process of making my asp.net form to validate as xhtml 1.0 strict. So far I am doing well, but now I have a problem. The problem concerns specifically DropDownList and...
1
by: mostafahamdyfcis | last post by:
Hello all I have used the sample code which exist in the following URL: http://www.eggheadcafe.com/articles/javascript_modal_dialog.asp which create modal dialog box, but some problem...
4
by: r_ahimsa_m | last post by:
Hello, I am learning WWW technologies in Linux. I created index.html file which I can browse with Firefox/Konqueror using URL localhost/~robert/rozgloszenia/index.html. The page looks fine but...
1
by: paulyXvpf | last post by:
Hello javascript folks, PROBLEM: Javascript dropdown problem in IE 6 and IE7 DESCRIPTION: menu falls behind a container box on web page COMMENTS: It works fine in Firefox but not in IE 6/7...
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...
1
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.