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

Ways to validate form before submitting

I need to validate a form to ensure that all of the fields add up correctly.
I can't do this while the user is entering data since validation needs to be
done after the entry is completed. What's the "best" way to validate prior
to submitting?

I could add an onsubmit attribute to the form which executes the validation
in Javascript. That way the response doesn't need to be sent before
validation takes place. Is this pretty much the way to do it?

Thanks!
Bill
Nov 19 '05 #1
4 4246
Hi Bill:

The best approach would be to use a custom validator.

http://msdn.microsoft.com/library/de...torcontrol.asp

This approach will work with the validation framework in ASP.NET and validate
the page client side (with script) before the form posts back to the server
(and validates on the server side as well).

--
Scott
http://www.OdeToCode.com/blogs/scott/
I need to validate a form to ensure that all of the fields add up
correctly. I can't do this while the user is entering data since
validation needs to be done after the entry is completed. What's the
"best" way to validate prior to submitting?

I could add an onsubmit attribute to the form which executes the
validation in Javascript. That way the response doesn't need to be
sent before validation takes place. Is this pretty much the way to do
it?

Thanks!
Bill

Nov 19 '05 #2
"Wysiwyg" <wy*****@xmissionNSPAM.com> confessed in news:ct6man$v5c$1
@news.xmission.com:
I need to validate a form to ensure that all of the fields add up correctly. I can't do this while the user is entering data since validation needs to be done after the entry is completed. What's the "best" way to validate prior
to submitting?

I could add an onsubmit attribute to the form which executes the validation
in Javascript. That way the response doesn't need to be sent before
validation takes place. Is this pretty much the way to do it?

Thanks!
Bill


Bill,

You could hook the onchange event in JS, but ASP.NET WebForms have built in
validation controls, meant to check existance, regular expressions, etc.

There is also a custom validator control designed for you to place your own
code, ie, to check for disallow characters, a particular input format, etc.

The ASP.NET framwork takes care of when to fire, and manages the flow of
control for you. All your validator has to do is set an IsValid field to true
or false.

Check this out. Very slick indeed!

-- ipgrunt
Nov 19 '05 #3
I'm already using all of those types of validation on individual fields.
When individual fields are updated the displayed subtotals update with
client code set up with the custom validators, the number ranges are
checked, etc. However, an onchange event doesn't help when I need to
evaluate the data after the user has finished entry. There's no point in
validating whether or not the data adds up if the user hasn't finished
entering it yet.

I need to validate the entire form right before it is submitted. I'm looking
for ways to validate the form as a whole and not individual fields.

Bill

"IPGrunt" <me@privacy.net> wrote in message
news:Xn**********************************@130.133. 1.4...
"Wysiwyg" <wy*****@xmissionNSPAM.com> confessed in news:ct6man$v5c$1
@news.xmission.com:
I need to validate a form to ensure that all of the fields add up correctly.
I can't do this while the user is entering data since validation needs to be
done after the entry is completed. What's the "best" way to validate
prior to submitting?

I could add an onsubmit attribute to the form which executes the validation in Javascript. That way the response doesn't need to be sent before
validation takes place. Is this pretty much the way to do it?

Thanks!
Bill


Bill,

You could hook the onchange event in JS, but ASP.NET WebForms have built

in validation controls, meant to check existance, regular expressions, etc.

There is also a custom validator control designed for you to place your own code, ie, to check for disallow characters, a particular input format, etc.
The ASP.NET framwork takes care of when to fire, and manages the flow of
control for you. All your validator has to do is set an IsValid field to true or false.

Check this out. Very slick indeed!

-- ipgrunt

Nov 19 '05 #4
"Wysiwyg" <wy*****@xmissionNSPAM.com> confessed in news:ct8evp$89g$1
@news.xmission.com:
I'm already using all of those types of validation on individual fields.
When individual fields are updated the displayed subtotals update with
client code set up with the custom validators, the number ranges are
checked, etc. However, an onchange event doesn't help when I need to
evaluate the data after the user has finished entry. There's no point in
validating whether or not the data adds up if the user hasn't finished
entering it yet.

I need to validate the entire form right before it is submitted. I'm looking for ways to validate the form as a whole and not individual fields.

Bill

"IPGrunt" <me@privacy.net> wrote in message
news:Xn**********************************@130.133. 1.4...
"Wysiwyg" <wy*****@xmissionNSPAM.com> confessed in news:ct6man$v5c$1
@news.xmission.com:
> I need to validate a form to ensure that all of the fields add up

correctly.
> I can't do this while the user is entering data since validation needs to
be
> done after the entry is completed. What's the "best" way to validate

prior > to submitting?
>
> I could add an onsubmit attribute to the form which executes the validation > in Javascript. That way the response doesn't need to be sent before
> validation takes place. Is this pretty much the way to do it?
>
> Thanks!
> Bill
>
>


Bill,

You could hook the onchange event in JS, but ASP.NET WebForms have built

in
validation controls, meant to check existance, regular expressions, etc.

There is also a custom validator control designed for you to place your

own
code, ie, to check for disallow characters, a particular input format,

etc.

The ASP.NET framwork takes care of when to fire, and manages the flow of
control for you. All your validator has to do is set an IsValid field to

true
or false.

Check this out. Very slick indeed!

-- ipgrunt



Thanks for explaining. I guess I missed an earlier question?

Anyway, you sound like you've thought about this and are on the right track
toward doing what's required.

BTW, there is a validator summary control. Perhaps there's an event you can
hook that makes sense for your need?

Good luck.

-- ipgrunt
Nov 19 '05 #5

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

Similar topics

19
by: Pete | last post by:
I have form/select which executes a function using onchange. No problem. However, when I validate the page with a strict HTML 4.01 doctype at http://validator.w3.org, it demands either an action or...
5
by: Kit | last post by:
Hi there, I am recoding a website, and I want to add a generic footer to each page, using an included file with PHP snippets. Part of that footer would be a link to validate the page using the...
15
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
1
by: Johnny | last post by:
Hello, I've read somewhere that you can validate form data before actually submitting it, similar to what validation controls would do. For example, I have a form that has 2 textboxes. I...
9
by: B-Dog | last post by:
I have a form that has about 10 text boxes on it, they all have to be filled out before submitting is there a quick way to make sure that none are null or do I have to call out each textbox? Say...
2
by: juventusaurabh | last post by:
I have a form with a number of fields, some of which would be filled(populated) automatically from the MS SQL database on certain event.Now, I have certain validations on the fields from sql...
2
by: Bob | last post by:
I know how to use php/mysql, but the html aspect of what Im trying to do (if its even possible this way) is what Im unsure of. I want to have a button that a user can hit to valid mysql info...
3
by: Jeff | last post by:
I know how to use php/mysql, but the html aspect of what Im trying to do (if its even possible this way) is what Im unsure of. I want to have a button that a user can hit to valid mysql info...
8
by: chandhseke | last post by:
I have a form with various fields, one of which I need to check against data in a database table. i.e if the value entered into the text input field exists in the database, the form should be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.