473,769 Members | 6,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_s ave_stock.asp" method="post" name="MyFormDat a">
<input name="Make" type="text" id="MenuText" value=<% response.write
rsTable("Make") %size="50" maxlength="50">
<input name="DateBough t" id="MenuText" type="text" value=<% response.write
rsTable("DateBo ught") % 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_OnSu bmit = False "

Why ?

<Script language="vbscr ipt">
Function MyFormData_OnSu bmit()
Dim FormOkay

FormOkay=True

if isdate(MyFormDa ta.DateBought.V alue)=False then
msgbox "Error in date", vbokayonly+vbin formation,"Chec king Data"
MyFormData.Date Bought.SetFocus
FormOkay=False
end if

if FormOkay=False then
MyFormData_OnSu bmit = False
else
MyFormData_OnSu bmit = True
end if

end Function
</Script>

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

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

<Script language="vbscr ipt">

Function validate()

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

if isdate(TheForm. DateBought.Valu e)=False then
msgbox "Error in date", vbokayonly+vbin formation,"Chec king Data"
end if

end Function
</Script>

<form action="admin_s ave_stock.asp" method="post" name="MyFormDat a" id="MyFormData " onsubmit="valid ate(); return false;"
language="jscri pt">
<input name="Make" id="Make" type="text" value="<%= rsTable("Make") %>" size="50" maxlength="50">
<input name="DateBough t" id="DateBought " type="text" value="<%= rsTable("DateBo ught") %>" size="10" maxlength="10">
<input name="Submit" TYPE="Submit" VALUE="Submit">

</form>


"MadMike42" <mi****@ntlworl d.comwrote in message news:yK******** **********@news fe5-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_s ave_stock.asp" method="post" name="MyFormDat a">
<input name="Make" type="text" id="MenuText" value=<% response.write rsTable("Make") %size="50" maxlength="50">
<input name="DateBough t" id="MenuText" type="text" value=<% response.write rsTable("DateBo ught") % 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_OnSu bmit = False "

Why ?

<Script language="vbscr ipt">
Function MyFormData_OnSu bmit()
Dim FormOkay

FormOkay=True

if isdate(MyFormDa ta.DateBought.V alue)=False then
msgbox "Error in date", vbokayonly+vbin formation,"Chec king Data"
MyFormData.Date Bought.SetFocus
FormOkay=False
end if

if FormOkay=False then
MyFormData_OnSu bmit = False
else
MyFormData_OnSu bmit = 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.supe rnews.com...
>I don't think there is a "setfocus"

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

<Script language="vbscr ipt">

Function validate()

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

if isdate(TheForm. DateBought.Valu e)=False then
msgbox "Error in date", vbokayonly+vbin formation,"Chec king Data"
end if

end Function
</Script>

<form action="admin_s ave_stock.asp" method="post" name="MyFormDat a"
id="MyFormData " onsubmit="valid ate(); return false;" language="jscri pt">
<input name="Make" id="Make" type="text" value="<%= rsTable("Make") %>"
size="50" maxlength="50">
<input name="DateBough t" id="DateBought " type="text" value="<%=
rsTable("DateBo ught") %>" size="10" maxlength="10">
<input name="Submit" TYPE="Submit" VALUE="Submit">

</form>


"MadMike42" <mi****@ntlworl d.comwrote in message
news:yK******** **********@news fe5-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_s ave_stock.asp" method="post" name="MyFormDat a">
<input name="Make" type="text" id="MenuText" value=<% response.write
rsTable("Make" ) %size="50" maxlength="50">
<input name="DateBough t" id="MenuText" type="text" value=<%
response.wri te rsTable("DateBo ught") % 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_OnSu bmit = False "

Why ?

<Script language="vbscr ipt">
Function MyFormData_OnSu bmit()
Dim FormOkay

FormOkay=Tru e

if isdate(MyFormDa ta.DateBought.V alue)=False then
msgbox "Error in date", vbokayonly+vbin formation,"Chec king Data"
MyFormData.Date Bought.SetFocus
FormOkay=False
end if

if FormOkay=False then
MyFormData_OnSu bmit = False
else
MyFormData_OnSu bmit = 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
14021
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 dosent meet these requirments an error message will be displayed. I have pasted the code (and highlighted the relevant parts) below in the hope that someone can help me out with this. Ive been trying to suss it out all week & it's driving me nuts!...
3
2175
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 onchange/on blur to activate a javascript function to check the input for correctness once user moves out of the input box (tab or mouse click). If it looks OK, then nothing happens. But if an error is detected, the function puts out an alert box...
1
4892
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" onsubmit="return(checkAll(this))"> <label>Username<br /><input id="input" type="text" name="username" /></label><br /> <label>Email<br /><input id="input" type="text" name="email" /></label><br /> <label>Password<br /><input...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6673
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
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 we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.