javascript form validaion won't post to asp page

I

iam247

Hi

I have an asp page without any javascript. It posts the content of a
form to another page, which reads the form fields using Request.Form.

This is the form header:

<form name=form method=post action=RegDetails.asp>

I have tried to modify the form by adding javascript for password
validation. The script came from:

http://javascript.internet.com/forms/val-pass.html

The form header from this javascript is:

<form name=myForm onSubmit="return validatePwd()">

This header validates my passwords ok but obviously is missing,
method=post & action=RegDetails.asp

When have combined the to form headers to give:

<form name=myform method=post onSubmit="return validatePwd()"
action=RegDetails.asp>

This header still validates the password but does not Post to
RegDetails.asp

On pressing submit the form fields are sent via the url as a
querystring, back to the same form/page which opens blank.

I would appreciate help in using the javascript to validate my form but
still Post the form values to RegDetails.asp

Thanks ColinK
 
S

Stefan B Rusynko

Just the onsubmit to the form attributes you had
<form name=form method=post action=RegDetails.asp onSubmit="return validatePwd()">

You could do the same filed validation as that script by just using FP form field validation w/o the script





| Hi
|
| I have an asp page without any javascript. It posts the content of a
| form to another page, which reads the form fields using Request.Form.
|
| This is the form header:
|
| <form name=form method=post action=RegDetails.asp>
|
| I have tried to modify the form by adding javascript for password
| validation. The script came from:
|
| http://javascript.internet.com/forms/val-pass.html
|
| The form header from this javascript is:
|
| <form name=myForm onSubmit="return validatePwd()">
|
| This header validates my passwords ok but obviously is missing,
| method=post & action=RegDetails.asp
|
| When have combined the to form headers to give:
|
| <form name=myform method=post onSubmit="return validatePwd()"
| action=RegDetails.asp>
|
| This header still validates the password but does not Post to
| RegDetails.asp
|
| On pressing submit the form fields are sent via the url as a
| querystring, back to the same form/page which opens blank.
|
| I would appreciate help in using the javascript to validate my form but
| still Post the form values to RegDetails.asp
|
| Thanks ColinK
|
 
I

iam247

Hi Stephan

Thanks for your continued interest.

I am not clear on the first part of your answer:

Just the onsubmit to the form attributes you had
<form name=form method=post action=RegDetails.asp onSubmit="return
validatePwd()">

This the same as my form header except name=myform (just to match the
javascript)

Hopefully the following will more accurately clarify the problem.
If I copy all of the script from:
http://javascript.internet.com/forms/val-pass.html

Into a new page, the validation works fine. If the 2 passwords match
the final result is:
1. The "nice Job" alert pops up
2. A blank form reloads with the original url + the querystring of
Password 1& 2
eg
http://localhost/gc7/www/pass.asp?password=123456&password2=123456

If I remove the complete line for the last alert
alert('Nice job.');

Result 1 above obviously does not work but result 2 does.

The Problem

If I change the form header from the original to any of the 2
alternatives - shown at bottom (from my own original non validating
page) The form does not validate the passwords but post to
RegDetails.asp - same as my own original.

I want to be able to validate and post - but I can't do both

Thanks ColinK
ORIGINAL
<form name=myForm onSubmit="return validatePwd()">
ALTERNATIVE1
<form name="myform" method="post" onSubmit="return validatePwd()"
action="RegDetails.asp">
ALTERNATIVE2
<form name=myform method=post onSubmit="return validatePwd()"
action=RegDetails.asp>

Note I have 2 alternatives as the javascript did not seem to like the
"" in some parts of my original page.
 
P

p c

try putting semicolon in the javacript line

<form name=myForm onSubmit="return validatePwd();">

...PC
 
I

iam247

Thanks for your suggestion.
The original works fine with or without a ;
<form name=myForm onSubmit="return validatePwd()">
OR
<form name=myForm onSubmit="return validatePwd();">

My alternative 1 still posts without validating via the javascript with
or without a ;
<form name="myform" method="post" onSubmit="return validatePwd()"
action="RegDetails.asp">
OR
<form name="myform" method="post" onSubmit="return validatePwd();"
action="RegDetails.asp">

Even if I move the validatePwd() to the end it still does not validate
with or wothout the ;
<form name="myform" method="post"
action="RegDetails.asp" onSubmit="return validatePwd();">

Thanks ColinK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top