473,804 Members | 3,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Validation Redux

First off wanted to that all that replied to my previous questions, you were
much help.

Had a couple of general questions.

Why has everyone suggested not using VB Script on the Client Side?

Secondly, I have decided to do my validation on the processing page.
If a field on the form does not meet the validation rules, I am able to
redirect back to the sending page. How do I do this so that the sending
page retains the values that the Client had previously put in so that he
only
needs to correct the fields that are not valid?

Thanks for helping out the nuuubeeeee.....

rh
Jul 19 '05 #1
11 1813
VBScript on the client, only works in IE....as far as I know.

For the second thingy, I will often post to the same page.....

Example.asp

<%
Dim sUser
Dim sPass

sUser=Request.F orm("user")
sPass=Request.F orm("pass")
'VALIDATION CODE HERE.......

%>

<form method=post action=Example. asp>
Username:<input name="user" value="<%=sUser %>"><br>
Password:<input name="pass" value="<%=sPass %>"><br>
<input type=submit value="submit">
</form>
Note that the action is set to Example.asp the same name as the current
page.
"r0adhog" <ro*****@nospam .phreaker.net> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
First off wanted to that all that replied to my previous questions, you were much help.

Had a couple of general questions.

Why has everyone suggested not using VB Script on the Client Side?

Secondly, I have decided to do my validation on the processing page.
If a field on the form does not meet the validation rules, I am able to
redirect back to the sending page. How do I do this so that the sending
page retains the values that the Client had previously put in so that he
only
needs to correct the fields that are not valid?

Thanks for helping out the nuuubeeeee.....

rh

Jul 19 '05 #2

"r0adhog" <ro*****@nospam .phreaker.net> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..

Why has everyone suggested not using VB Script on the Client Side?
Because Internet Explorer is the only browser that supports it. Even if
you're working on an intranet and you know that all your visitors are using
IE, it's still highly ill-advised to use VBS. One day your intranet will
become an extranet, and then you'll have to recode it all. If you don't
know javascript, bite the bullet and learn enough to get by with what you
have to do.

Secondly, I have decided to do my validation on the processing page.
If a field on the form does not meet the validation rules, I am able to
redirect back to the sending page. How do I do this so that the sending
page retains the values that the Client had previously put in so that he
only
needs to correct the fields that are not valid?


There are a number of ways. One is to post the form to the same page that
it's on.

form.asp:

<%
If request.serverV ariables("REQUE ST_METHOD") = "POST" Then
'''do your thing
End If
%>

<form method="post" action="form.as p">
<input name="txtName"
value="<%=Serve r.HTMLEncode(Re quest.Form("txt Name"))%>" type="text" />
</form>

If the form is being loaded for the first time, REquest.Form("t xtName") will
be empty, so you'll have an empty value. If the form has been submitted and
you're redisplaying it because of failed validation, anything the user had
previously entered in that textbox will be pulled from the form collection
and displayed in it.
If you don't want to post to the same page, you can set the values in
session variables and pull from them. The first method is easier, but then
you wind up having pages that can't be refreshed without the "Warning. By
refreshing this page, any data you submitted will be sent again..." or
whatever that browser warning is.

Ray at work
Jul 19 '05 #3
Thanks again folks!

rh

"r0adhog" <ro*****@nospam .phreaker.net> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
First off wanted to that all that replied to my previous questions, you were much help.

Had a couple of general questions.

Why has everyone suggested not using VB Script on the Client Side?

Secondly, I have decided to do my validation on the processing page.
If a field on the form does not meet the validation rules, I am able to
redirect back to the sending page. How do I do this so that the sending
page retains the values that the Client had previously put in so that he
only
needs to correct the fields that are not valid?

Thanks for helping out the nuuubeeeee.....

rh

Jul 19 '05 #4
"r0adhog" wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
: Secondly, I have decided to do my validation on the processing page.
: If a field on the form does not meet the validation rules, I am able to
: redirect back to the sending page. How do I do this so that the sending
: page retains the values that the Client had previously put in so that he
: only needs to correct the fields that are not valid?

I prefer to use client-side validation, no matter where I post to (same page
or different page). Unless you need information from the server, there's no
need to make that trip.

-- mypage.asp --

<script type="text/javascript">
function validate() {
var ename=document. getElementById( "iname");
if(!ename.value ) {
alert("Please enter your name");
ename.focus();
return false;
} else {

document.myform .action="<%=Req uest.ServerVari ables("SCRIPT_N AME")%>";
document.myform .submit();
}
}
</script>

<form name="myform" method="post" onsubmit="retur n validate()">
What is your name?<br />
<input type="text" id="iname" name="iname" value="" /><br />
<input type="submit" value="Submit" />
</form>

HTH...
Jul 19 '05 #5
You should always do both, it's easy to spoof a form. Also, not all clients
support javascript.
"Roland Hall" <nobody@nowhere > wrote in message
news:ut******** ******@TK2MSFTN GP09.phx.gbl...
"r0adhog" wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
: Secondly, I have decided to do my validation on the processing page.
: If a field on the form does not meet the validation rules, I am able to
: redirect back to the sending page. How do I do this so that the sending
: page retains the values that the Client had previously put in so that he
: only needs to correct the fields that are not valid?

I prefer to use client-side validation, no matter where I post to (same page or different page). Unless you need information from the server, there's no need to make that trip.

-- mypage.asp --

<script type="text/javascript">
function validate() {
var ename=document. getElementById( "iname");
if(!ename.value ) {
alert("Please enter your name");
ename.focus();
return false;
} else {

document.myform .action="<%=Req uest.ServerVari ables("SCRIPT_N AME")%>";
document.myform .submit();
}
}
</script>

<form name="myform" method="post" onsubmit="retur n validate()">
What is your name?<br />
<input type="text" id="iname" name="iname" value="" /><br />
<input type="submit" value="Submit" />
</form>

HTH...

Jul 19 '05 #6
TomB wrote:
You should always do both, it's easy to spoof a form. Also, not all
clients support javascript.


You should certainly always do the server-side validation, but there is no
compelling reason to require the client-side type.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #7

"Dave Anderson" <GT**********@s pammotel.com> wrote in message
news:OR******** ******@TK2MSFTN GP10.phx.gbl...

You should certainly always do the server-side validation, but there is no
compelling reason to require the client-side type.


If nothing else, it's certainly much quicker to see an alert('Please enter a
valid whatever') than to wait for the form to post and the page to reload
with the validation message.

Personally, I don't do client-side validation, but I see why people would.

Ray at home
Jul 19 '05 #8
"TomB" wrote in message news:u4******** ******@tk2msftn gp13.phx.gbl...
: You should always do both, it's easy to spoof a form. Also, not all
clients
: support javascript.

On the server-side I validate that the form is submitted from only the page
intended and not from another site but data is already validated at that
point and of course you weed out the SQL injection attempts but that's not
really validating, is it?
Jul 19 '05 #9
I was just responding to the previous post, trying to indicate that
client-side only was not sufficient.
"Dave Anderson" <GT**********@s pammotel.com> wrote in message
news:OR******** ******@TK2MSFTN GP10.phx.gbl...
TomB wrote:
You should always do both, it's easy to spoof a form. Also, not all
clients support javascript.
You should certainly always do the server-side validation, but there is no
compelling reason to require the client-side type.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.

Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 19 '05 #10

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

Similar topics

17
8297
by: Phil Powell | last post by:
Where can I find an online PHP form validator script library to use? I have tried hacking the one here at work for weeks now and it's getting more and more impossible to customize, especially now with form elements that turn out to be arrays that have to be compared with one another! I have one form element, languages, a checkbox group. Beside each checkbox is a dropdown, proficiency (which will become proficiency alongside languages)....
4
9985
by: TG | last post by:
I have a validation form that must behave differently based on the results of a PHP validation check. I have a post command at the top of my form that calls itself. I don't leave the form when performing the validation check on the values that were entered into the form, I simply repost the form to perform the PHP validation. If any of the values that have been entered into the form are incorrect, I display a warning message on the screen...
1
1962
by: Sue | last post by:
Anyone have any ideas on why the code below will show up in a browser's sourcecode as an empty table, and is not visible? aspx: <headertemplate> <asp:Table ID="MyTable" runat="server" /> </headertemplate>
4
2654
by: bnp | last post by:
Hi All, I am quite new the JavaScript. Basically I am a C++ programmer, but now I am working on JavaScript since last 5 days. I have a problem regarding the form validation. I have created a script that validates the form fields. the validation procedure is called ONCLICK event of the submit button. Follwowing is the structure of the validation procedure.
16
2253
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate individual fields, such as an "Email Validation Script" or a "Phone Validation Script". Is it ok to put all these scripts on page as they are or should they be joined in some way together to be one script? I'm a total JavaScript newbie and am completely...
9
4181
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be honest I usually hire someone to do it for me, grab predone scripts and kind of hack out the parts that I need, or just do very minimal validation (e.g. this is numeric, this is alpha-numeric, etc.)
7
7000
by: h7qvnk7q001 | last post by:
I'm trying to implement a simple server-side form validation (No Javascript). If the user submits a form with errors, I want to redisplay the same form with the errors highlighted. Once the form is correct I need to submit to another page that uses the form data. I first tried making the form submit action= field point to the same file. When the form was correct, I tried loading the next page by using <META http-equiv refresh>. But...
27
4760
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it appears that the data goes straight to the processing page, rather than the javascript seeing if data is missing and popping up an alert. I thought it may be because much of the form is populated with data from the db (lists, etc.), but when I leave...
11
3002
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether certain fields match certain criteria, and inform the user in different ways when the data is wrong (offcourse, this will be checked on posting the data again, but that's something I've got a lot of experience with). Now, offcourse it's...
0
9704
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
10562
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10319
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10303
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
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
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4282
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
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2978
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.