check input field, only numbers accepted 
Author Message
 check input field, only numbers accepted

Hi,

I have a input field, where only numbers (no letters or other signs)
will be accepted. When confirming the button, the asp-page will be
reloaded, the field value will be saved into a cookie and will be shown
on the screen.
My problem is now, that I only want to accept numbers. How can I check
it? When a letter is written and confirmed, a default value shall be
saved into the cookie, instead of the letter.

Thanks for your help.

Daniel



Mon, 15 Dec 2003 06:17:32 GMT  
 check input field, only numbers accepted
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>

<Script language="VBScript">

function CheckText()
 If isNumeric(mytext.value) Then
  'submit the form write the cookie etc...
 Else
  MsgBox "You must enter a number!"
 End IF
End function
</script>
</HEAD>
<BODY>

<input type="text" Name="mytext">

<input type="button" Onclick="CheckText()" Value="Go!">

</BODY>
</HTML>

Bryan Martin


: Hi,
:
: I have a input field, where only numbers (no letters or other signs)
: will be accepted. When confirming the button, the asp-page will be
: reloaded, the field value will be saved into a cookie and will be shown
: on the screen.
: My problem is now, that I only want to accept numbers. How can I check
: it? When a letter is written and confirmed, a default value shall be
: saved into the cookie, instead of the letter.
:
: Thanks for your help.
:
: Daniel
:



Mon, 15 Dec 2003 06:48:46 GMT  
 check input field, only numbers accepted
If you won't let users enter letters in the input box, just use the
onchange or onkeydown event of the input field to prevent that. Otherwise,
you can check that before submit the form.

Thanks,

Robin



Mon, 15 Dec 2003 17:31:38 GMT  
 check input field, only numbers accepted
Bryan Martin escribi:

Quote:
> <HTML>
> <HEAD>
> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
> <TITLE></TITLE>

> <Script language="vbscript">

> function CheckText()
>  If isNumeric(mytext.value) Then
>   'submit the form write the cookie etc...
>  Else
>   MsgBox "You must enter a number!"
>  End IF
> End function
> </script>
> </HEAD>
> <BODY>

> <input type="text" Name="mytext">

> <input type="button" Onclick="CheckText()" Value="Go!">

> </BODY>
> </HTML>

OK, thank you, it works fine with MS IE, but not with Netscape. Why? What do
I have to change?

Thanks.
Daniel



Tue, 16 Dec 2003 06:25:49 GMT  
 check input field, only numbers accepted
Netscape doesn't support VBScript, please use JScript instead.

Thanks,

Robin



Tue, 16 Dec 2003 17:17:07 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Checking input number

2. Check if input is number or text?

3. checking to make sure that an input is a number

4. Checking for input field

5. field validation and input checking

6. Field Validation or Input checking

7. Piechart with varying number of input fields

8. Input Masking for phone number fields

9. accept password without displaying input ?

10. Can VBScript accept user input over a network?

11. Form becomes active window but won't accept input with Wizard running behind it

12. Form becomes active window but won't accept input with Wizard running behind it

 

 
Powered by phpBB® Forum Software