close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Validating DataAssist Insert Form

Thread begun 11/02/2009 8:50 am by bill173836 | Last modified 11/03/2009 9:25 am by Jason Byrnes | 5493 views | 9 replies |

bill173836

Validating DataAssist Insert Form

I'm trying to validate several items in my insert data form. But when the validation error window pops up and I click okay the form submits. Obviously I don't want it to do that until all items are validated. Here is the javascript I'm using:

<script LANGUAGE="JavaScript">
<!--
function ValidateForm(form){
ErrorText= "";
if ( form.merchant.value == "") { alert ( "Merchant Name is a required field" ); return false; }
if ( form.contact.value == "") { alert ( "Contact Name is a required field" ); return false; }
if ( form.metro.selectedIndex == 0 ) { alert ( "You must choose a Metropolitan Area." ); return false; }
if ( form.terms.checked == false ) { alert ( "Please check the Terms & Conditions box." ); return false; }

if (ErrorText= "") { form.submit() }
}
-->
</script>

On the form submit button I have:
<input type="image" name="Insert" id="Insert" value="Insert" alt="Insert" src="images/SubmitButton.jpg" onClick="ValidateForm(this.form);" />

I'm also trying to check to see if there is a duplicate entry in the email field of my form and confirm the password. Any suggestions?
Thank You.

Sign in to reply to this post

Jason ByrnesWebAssist

your javascriipt code does no do anything with the ErrorText variable.

you initially set it to:
ErrorText= "";

but do not change it when a validation fails.


By the time it gets down to the if statement to submit the form:
if (ErrorText= "") { form.submit() }
}

ErrorText will always equal "".


try changing your validation if statements to change the ErrorText variable:
if ( form.merchant.value == "") { ErrorText= "1";alert ( "Merchant Name is a required field" ); return false; }




Our CSS Form builder tool includes Client Side and Server Side validation behaviors. you may want to try using those.

Sign in to reply to this post

bill173836

I tried what you suggested and the form still submits to the next page.

<script LANGUAGE="JavaScript">
<!--
function ValidateForm(form){

if ( form.merchant.value == "") { ErrorText= "1";alert ( "Merchant Name is a required field" ); return false; }
if ( form.contact.value == "") { ErrorText= "2";alert ( "Contact Name is a required field" ); return false; }
if ( form.metro.selectedIndex == 0 ) { ErrorText= "3";alert ( "You must choose a Metropolitan Area." ); return false; }
if ( form.terms.checked == false ) { ErrorText= "4";alert ( "Please check the Terms & Conditions box." ); return false; }

if (ErrorText= "") { form.submit() }
}
-->
</script>

Sign in to reply to this post

Jason ByrnesWebAssist

this is because you are performing the validation on the onClick event of the submit button.

See the following for a tutorial on creating javascript validation:
form-validation-with-javascript/

Sign in to reply to this post

bill173836

What other event would I do it on? I've tried focus and it doesn't work. Here is my code again what is wrong and what should it be? Thank you for the help. I'm under the gun to get this out today.

<script LANGUAGE="JavaScript">
<!--
function ValidateForm(form){

if ( form.merchant.value == "") { ErrorText= "1";alert ( "Merchant Name is a required field" ); return false; }
if ( form.contact.value == "") { ErrorText= "2";alert ( "Contact Name is a required field" ); return false; }
if ( form.metro.selectedIndex == 0 ) { ErrorText= "3";alert ( "You must choose a Metropolitan Area." ); return false; }
if ( form.terms.checked == false ) { ErrorText= "4";alert ( "Please check the Terms & Conditions box." ); return false; }
}
-->
</script>

<input name="Insert" type="image" id="Insert" onClick="ValidateForm(this.form)" value="Insert" src="images/SubmitButton.jpg" alt="Insert" />

Sign in to reply to this post

Jason ByrnesWebAssist

validation should occur on the submit event of the form.


you script will not work though, even on the submit event, that is why I pointed you tword the tutorial.

We do not offer support javascript that you hand code, our CSS Form Builder tool has Client side (Javascript) Validation built into it. If you are trouble creating your own validation script, you should consider using the Client validation in CSS form Builder.

Sign in to reply to this post

bill173836

I've tried using both Validation Toolkit and CSS Form Builder and get a javascript error every time. I posted in the Validation Toolkit forum with the error and really haven't gotten a solution to my problem yet. That is why I tried to do it without either extension.

Sign in to reply to this post

Jason ByrnesWebAssist

from what I can see in the other thread, you have both Validation Toolkit and CSS Form builder installed at the same time.


maybe try step 2 on the following link:
146/


then install form builder, after installing form builder, see the Known Issues section on the form builder download page before starting Dreamweaver.

Sign in to reply to this post

bill173836

I've gone back to trying to use the CSS Form Builder and it appears that the issue is with the required field. Most of the validation elements seem to work okay.

Sign in to reply to this post

Jason ByrnesWebAssist

Did you install the updated files in the known issue section of the CSS From Builder download page?

Sign in to reply to this post
loading

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...