473,395 Members | 1,578 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,395 software developers and data experts.

validating input boxes

This is really starting to annoy me,
I've got a form, that has some input boxes,
a example of the code is here:-

<form action="admin_save_stock.asp" method="post" name="MyFormData">
<input name="Make" type="text" id="MenuText" value=<% response.write
rsTable("Make") %size="50" maxlength="50">
<input name="DateBought" id="MenuText" type="text" value=<% response.write
rsTable("DateBought") % size="10" maxlength="10">
</form>

I also have a FUNCTION that checks to make sure the dates etc are correct :-
But, the code will work as far as giving me the error MSGBOX
but it still posts to the next page for some reason its
ignoring the " MyFormData_OnSubmit = False "

Why ?

<Script language="vbscript">
Function MyFormData_OnSubmit()
Dim FormOkay

FormOkay=True

if isdate(MyFormData.DateBought.Value)=False then
msgbox "Error in date", vbokayonly+vbinformation,"Checking Data"
MyFormData.DateBought.SetFocus
FormOkay=False
end if

if FormOkay=False then
MyFormData_OnSubmit = False
else
MyFormData_OnSubmit = True
end if

end Function
</Script>

thankls
Mike.
Oct 28 '06 #1
2 1472
I don't think there is a "setfocus"

try this
=============================

<Script language="vbscript">

Function validate()

Dim FormOkay
FormOkay=True
Set TheForm = Document.forms("MyFormData")

if isdate(TheForm.DateBought.Value)=False then
msgbox "Error in date", vbokayonly+vbinformation,"Checking Data"
end if

end Function
</Script>

<form action="admin_save_stock.asp" method="post" name="MyFormData" id="MyFormData" onsubmit="validate(); return false;"
language="jscript">
<input name="Make" id="Make" type="text" value="<%= rsTable("Make") %>" size="50" maxlength="50">
<input name="DateBought" id="DateBought" type="text" value="<%= rsTable("DateBought") %>" size="10" maxlength="10">
<input name="Submit" TYPE="Submit" VALUE="Submit">

</form>


"MadMike42" <mi****@ntlworld.comwrote in message news:yK******************@newsfe5-win.ntli.net...
This is really starting to annoy me,
I've got a form, that has some input boxes,
a example of the code is here:-

<form action="admin_save_stock.asp" method="post" name="MyFormData">
<input name="Make" type="text" id="MenuText" value=<% response.write rsTable("Make") %size="50" maxlength="50">
<input name="DateBought" id="MenuText" type="text" value=<% response.write rsTable("DateBought") % size="10" maxlength="10">
</form>

I also have a FUNCTION that checks to make sure the dates etc are correct :-
But, the code will work as far as giving me the error MSGBOX
but it still posts to the next page for some reason its
ignoring the " MyFormData_OnSubmit = False "

Why ?

<Script language="vbscript">
Function MyFormData_OnSubmit()
Dim FormOkay

FormOkay=True

if isdate(MyFormData.DateBought.Value)=False then
msgbox "Error in date", vbokayonly+vbinformation,"Checking Data"
MyFormData.DateBought.SetFocus
FormOkay=False
end if

if FormOkay=False then
MyFormData_OnSubmit = False
else
MyFormData_OnSubmit = True
end if

end Function
</Script>

thankls
Mike.


Oct 29 '06 #2
That's it !

I changed from .SetFocus to just .Focus and it worked
many thanks
Mike.
"Jon Paal" <Jon nospam Paal @ everywhere dot comwrote in message
news:12*************@corp.supernews.com...
>I don't think there is a "setfocus"

try this
=============================

<Script language="vbscript">

Function validate()

Dim FormOkay
FormOkay=True
Set TheForm = Document.forms("MyFormData")

if isdate(TheForm.DateBought.Value)=False then
msgbox "Error in date", vbokayonly+vbinformation,"Checking Data"
end if

end Function
</Script>

<form action="admin_save_stock.asp" method="post" name="MyFormData"
id="MyFormData" onsubmit="validate(); return false;" language="jscript">
<input name="Make" id="Make" type="text" value="<%= rsTable("Make") %>"
size="50" maxlength="50">
<input name="DateBought" id="DateBought" type="text" value="<%=
rsTable("DateBought") %>" size="10" maxlength="10">
<input name="Submit" TYPE="Submit" VALUE="Submit">

</form>


"MadMike42" <mi****@ntlworld.comwrote in message
news:yK******************@newsfe5-win.ntli.net...
>This is really starting to annoy me,
I've got a form, that has some input boxes,
a example of the code is here:-

<form action="admin_save_stock.asp" method="post" name="MyFormData">
<input name="Make" type="text" id="MenuText" value=<% response.write
rsTable("Make") %size="50" maxlength="50">
<input name="DateBought" id="MenuText" type="text" value=<%
response.write rsTable("DateBought") % size="10" maxlength="10">
</form>

I also have a FUNCTION that checks to make sure the dates etc are correct
:-
But, the code will work as far as giving me the error MSGBOX
but it still posts to the next page for some reason its
ignoring the " MyFormData_OnSubmit = False "

Why ?

<Script language="vbscript">
Function MyFormData_OnSubmit()
Dim FormOkay

FormOkay=True

if isdate(MyFormData.DateBought.Value)=False then
msgbox "Error in date", vbokayonly+vbinformation,"Checking Data"
MyFormData.DateBought.SetFocus
FormOkay=False
end if

if FormOkay=False then
MyFormData_OnSubmit = False
else
MyFormData_OnSubmit = True
end if

end Function
</Script>

thankls
Mike.



Oct 29 '06 #3

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

Similar topics

3
by: Mark | last post by:
Hi, Im trying to validate a form, all the validating works apart from one field. This particular field must consist of the first 2 characters as letters, & the following 5 as numbers. And if it...
3
by: Louis | last post by:
I have a form with multiple input boxes. I want to validate each input box (and force user to correct it) before allowing user to move to another, either using tab key or a mouse click. I try...
1
by: lolcat | last post by:
Hi guys, new here and to javascript, I have this form that I am trying to you javascript to validate the multiple input text boxes. form as follows <form action="login.php" method="post"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.