|
-
Oct 11th, 2001, 05:23 AM
#1
Thread Starter
Fanatic Member
Pls Help. How to cancel a form submit with vbscript.
I have a form with a submit button. I want to perform some checking before submitting the form. How do i cancel a submit after the user has clicked the button?
-
Oct 11th, 2001, 07:36 AM
#2
Conquistador
try to run the validation code thru:
<form method="POST" action="register.cgi" onSubmit="runsomething>
get it?
-
Oct 12th, 2001, 05:00 AM
#3
Hyperactive Member
You can do it with javascript !
Code:
<script language="javascript">
function myValidateRoutine(my_form){
//do my form validation
}
</script>
<form method="POST" action="register.cgi" onSubmit="myValidateRoutine(this.form); return false;">
-
Oct 12th, 2001, 10:51 PM
#4
Fanatic Member
Shouldn't that be:
<script language="JavaScript">
function Validate(frmName){
//Check data here
if(good_data){
//if the data is good return true
return true;
}
else
//no good
return false;
}//end function
</script>
<form METHOD = "post" onSubmit="return Validate(this);">
Wouldn't the way you have it written cancel it anyway?
-
Oct 15th, 2001, 03:10 AM
#5
Hyperactive Member
Yes your right it would cancel it but the form would be submitted by javascript from within the function if the validation is ok.
When you submit the form using javascript it by-passes the onSubmit atrribute of the form.
Either way doesn't matter you just need to have a false value in there. Othewise it will try to go to the script in the action attribute of the form.
I like the way you did it though
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|