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

How to handle invalid entries in form submission

Does anybody have a nice method of forcing a user to enter a value into a
form using asp?
I think the best is to have a popup when they hit submit that will stay on
the same page and then just alert the user to enter something in so and so
text box.

Thanks in advance

Jul 19 '05 #1
5 2112
CJM
You have three basic approaches for data validation:

1) Client-side: Use javascript to check the form data before it is posted.
2) Server-side: Use ASP to check the posted data and react accordingly
3) Use both - which is, needless to say, the recommended route IMHO

The scenario you talk about comes under category 1), and and would use
Javascript. In my case, this is usually not a problem since most of my work
is intranet based, so I know about my clients. If your project is on the
internet, you should proceed with caution - 13% of users do not have
javascript or have it disabled. If you are prepared to risk this, or if this
is not an issue, I can send you a client-side validation scipt that I use -
you can modify to fit your needs.

Clearly you could just opt for a server-side validation solution; the
disadvantage is that it requires a few more trips across the lines, and it
is slightly different to code, but it would work for all clients. If you
want to be as inclusive and thorough as possible you should choose this
option.

In most of my apps, I use client-side validation to check that numeric
fields are indeed numeric, mandatory fields or filled in, listboxes have
selected items etc... When the forms are submitted, I do further checks,
including checks for SQL injection. The client-side validation checks the
basics, and the server-side validations looks into the detail.

I realise that this is quite a 'shotgun response' to your question, but I'm
trying look at a broader scope. Yes, you can achieve what you asked using
javascript, but whether you should is up to you.

Chris

http://www.brightnorth.com/snippets/
'validation master' is the full readable version, 'validation.js' is the
crunched version (half the size)
"Danny" <da********@hotmail.com> wrote in message
news:Jl*********************@news4.srv.hcvlny.cv.n et...
Does anybody have a nice method of forcing a user to enter a value into a
form using asp?
I think the best is to have a popup when they hit submit that will stay on
the same page and then just alert the user to enter something in so and so
text box.

Thanks in advance

Jul 19 '05 #2
I originally went with client-side myself, and then converted to
server-side since the page that I was sending to my visitors ended up
being incredibly HUGE. My thinking is that I'd prefer another round-trip
to the server as oppposed to having the visitor wait for the page to
load. It also allowed me to hide some validation that I'd prefer to keep
private.

David H.

http://www.gatewayorlando.com/conten...tV3_submit.asp

CJM wrote:
You have three basic approaches for data validation:

1) Client-side: Use javascript to check the form data before it is posted.
2) Server-side: Use ASP to check the posted data and react accordingly
3) Use both - which is, needless to say, the recommended route IMHO

The scenario you talk about comes under category 1), and and would use
Javascript. In my case, this is usually not a problem since most of my work
is intranet based, so I know about my clients. If your project is on the
internet, you should proceed with caution - 13% of users do not have
javascript or have it disabled. If you are prepared to risk this, or if this
is not an issue, I can send you a client-side validation scipt that I use -
you can modify to fit your needs.

Clearly you could just opt for a server-side validation solution; the
disadvantage is that it requires a few more trips across the lines, and it
is slightly different to code, but it would work for all clients. If you
want to be as inclusive and thorough as possible you should choose this
option.

In most of my apps, I use client-side validation to check that numeric
fields are indeed numeric, mandatory fields or filled in, listboxes have
selected items etc... When the forms are submitted, I do further checks,
including checks for SQL injection. The client-side validation checks the
basics, and the server-side validations looks into the detail.

I realise that this is quite a 'shotgun response' to your question, but I'm
trying look at a broader scope. Yes, you can achieve what you asked using
javascript, but whether you should is up to you.

Chris

http://www.brightnorth.com/snippets/
'validation master' is the full readable version, 'validation.js' is the
crunched version (half the size)
"Danny" <da********@hotmail.com> wrote in message
news:Jl*********************@news4.srv.hcvlny.cv.n et...
Does anybody have a nice method of forcing a user to enter a value into a
form using asp?
I think the best is to have a popup when they hit submit that will stay on
the same page and then just alert the user to enter something in so and so
text box.

Thanks in advance



Jul 19 '05 #3
CJM

"David C. Holley" <Da**********@netscape.net> wrote in message
news:OM*************@TK2MSFTNGP11.phx.gbl...
I originally went with client-side myself, and then converted to
server-side since the page that I was sending to my visitors ended up
being incredibly HUGE.
This is a fair point, which is particularly relevant to one-off pages or to
complex validation routines. In my pages, I'm using the same js script again
& again - the first time you call a validated page you have an extra 6k to
download (not a huge amount!). Any subsequent page that uses the same
validation routines uses the cached version, which obviously has no
bandwidth overhead.
My thinking is that I'd prefer another round-trip
to the server as oppposed to having the visitor wait for the page to
load.
Unless your validation routine is THAT big, the client-side method will
usually still be the quicker.
It also allowed me to hide some validation that I'd prefer to keep
private.


Which is probably one of the best reasons you could give. Fair point.

CJM

Jul 19 '05 #4

"Danny" <da********@hotmail.com> wrote in message
news:Jl*********************@news4.srv.hcvlny.cv.n et...
Does anybody have a nice method of forcing a user to enter a value into a
form using asp?
I think the best is to have a popup when they hit submit that will stay on
the same page and then just alert the user to enter something in so and so
text box.

Thanks in advance


Thanks for both of your responses.
and thank you CJM for hte code. I look forward to experimenting.

David, i like the server side method as well.
But how do you handle this.
Do you give them back the same form with a message at the top? IF so, how
do you ensure the form still has the user data so they don't have to type it
all in again, also, do you call the same .asp page?

Thanks in advance
Danny
Jul 19 '05 #5
I handle the validation with three sub-scripts that are included into
the *.asp page that the first form submits to.

reservationRequestV3_Validation.asp
reservationRequestV3_Processing.asp
reservationRequestV3_InvalidCenter.asp

_Validation.asp obviously handles the validation. I approached the
validation by writing functions to validate the various TYPES of fields
(i.e. all text, phone number, select list, etc.) Then I use an variable
to capture the error returned by the function for the particular field
and if neccessary any applicable text message. The variables are named
(userNameValidationError, responseMethodValidationError,
userPhoneHomeValidationError, userPhoneHomeValidationText, etc.)

If all of the _validationError variables = 0, _Processing is executed to
process the request. '0' assumes that no error occurred.

If one or more of the _validationError variables <> 0, the
_InvalidCenter script executes. This script sends a new form to the
visitor indicating which fields are valid and which are not. If a
particular value is valid, a HIDDEN input is written with the value set
to <%resposne.write request("fieldName")%> to maintain the original
value. The value is then written as text to display it for reference. If
the value is invalid, a form field is written.

if nameValidationError = 0 then
'write a hidden form field with the value set to the NAME
'write the actual value as text so the user can see it
else
'write a form field with the value and highlight the field
'write an error message explaining the problem
end if

The INVALID FORM submits to _Validation.asp to allow the process to
execute again if needed.

I choose to split up the three scripts to make life easier in making
changes and debuggin since if all three were combined the total number
of lines would be horendeous(sp).

David H.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #6

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

Similar topics

4
by: evan.cooch | last post by:
Greetings. Suppose I have some function called "CheckIt" - some function to validate form data before submitting it to e CGI script. Pretend the name of the form is "TheForm". If I use the...
2
by: Andy Goldstein | last post by:
I have a table where all the TRs have an onClick handler registered. One (and only one) of the rows has 2 text input boxes, where each textbox has an onChange handler registered. Both the onClick...
0
by: Deep Purple | last post by:
I started with the following error... ------------------------------------------------------- An error occured while loading the schema with TargetNamespace 'http://www.w3.org/2001/XMLSchema'...
3
by: Gvnn | last post by:
Hi, I've a little problem, i've an asp.net page, with a runat server form, like this: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="index.aspx.vb" Inherits="indexGstPro"%> <HTML>...
1
by: JackM | last post by:
I'm not sure how I need to proceed on this and can use a bit of advice. I have a non-profit's web site that wishes to allow their members to fill out information regarding summer camp information...
8
by: yawnmoth | last post by:
Say I have the following HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <form action="">
6
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and...
2
by: Brett_A | last post by:
I have the following contact us submission form. http://www.remarkableleadershipbook.com/contact.asp When I submit using Firefox on either my laptop to my desktop, I get single entries in the...
1
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.