close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Form Submitting without Validation firing

Thread began 3/14/2012 9:26 am by Steve | Last modified 3/14/2012 2:26 pm by Jason Byrnes | 1244 views | 5 replies |

Steve

Form Submitting without Validation firing

Using Validation Toolkit version 2.3.5 I've added Behaviors on a Checkout Cart 5 page to fields such as the CC Number field. These applied the behavior at the field level such as :

php:
<input name="cc_number" type="text" id="cc_number" onblur="WAValidateCC(document.forms[0].cc_number,document.forms[0].cc_number.value,'- Invalid credit card number','','4:51:52:53:54:55:34:37:6011:',document.forms[0].cc_number,0,true)" value="" />



In the form tag there is the Behavior to show any errors :

php:
<form  action="confirm.php" method="post" name="ecart_checkout_form" onsubmit="WAAlertErrors('The following errors were found','Correct invalid entries to continue',true,false,false);return document.MM_returnValue">



Here is the eCart code on the same page:

php:
<?php

require_once( "webassist/framework/library.php" );
require_once( 
"webassist/framework/framework.php" );
?>

<?php
//WA eCart Include
require_once("WA_eCart/eCart1_PHP.php");
?>

<?php
$eCart1
->GetContent();
?>



<?php
if ($eCart1->IsEmpty())     {
  
$eCart1->redirStr "display.php";
  
$eCart1->cartAction "RedirectIfEmpty";
}
?>


<?php
// WA eCart Redirect
if ($eCart1->redirStr != "")     {
  
header("Location: ".$eCart1->redirStr);
}
?>




Why or what is causing the client side validation to not be called prior to the form submission?

Sign in to reply to this post

Jason ByrnesWebAssist

the onBlur event and onSubmit events are totally separate, you cannot show validation errors on form submit if the validation is happening onBlur.

to show the errors on the form submit, you need to add the validations to the onSubmit event as well as have the show validation errors behavior on submit.

Sign in to reply to this post

Steve

Thanks Jason,
But I should have mentioned the onBlur was also not producing a response. Maybe not tied to a div to display the message? And should the presence of such a message not prohibit the submission of the form?

Sign in to reply to this post

Jason ByrnesWebAssist

you need to add the Show Validation message behavior to the onBlur event.

the validation behavior only checks the value, the Show Validation error behavior shows the error.

using the onblur event will only show an error if the user places the cursor in the field, then changes to another field, that is the only time the on blur event is fired.

if you have the show validation errors behavior added to the onblur event, it will show the message and prevent the user from moving to the next field.

if the user never places the cursor in the form element though, it wont prevent the form from being submitted since the onBlur event will never have occured.

Sign in to reply to this post

Steve

So there is not much benefit from using a client side validation on the various txt fields. Better to use the onSubmit within the form tag and set all your validations in the following order:

topmost - Validate Form
field specific validation
field specific validation
field specific validation
last behavior - Show Validation Error

Is this correct?

Sign in to reply to this post

Jason ByrnesWebAssist

yes, that is correct.


the only benefit to using validation on the onBlur event is to give the user real time feed back as they fill the form in, it wont prevent the form from being submitted though, to prevent the form being submitted, you need to apply the validation to the onsubmit event

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...