Hexagora Forum
Hexagora Forum
Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Dynamic HTML Editor
 Dynamic HTML Editor
 Forms & required fields
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

anima3
Expert

Canada
96 Posts

Posted - 07 Feb 2009 :  16:17:31  Show Profile  Visit anima3's Homepage  Reply with Quote
Up until now I've always made my forms in HTML code boxes, just now I'm starting to use the form feature in DHE. So far it works, I've been able to send myself the information, so that's great. But there's one thing I've been able to do before, which I seem not to be able to do now: I've always inserted a Javascript which enables the form to refuse to send if there are some required fields that were not filled. The code goes like this:

<script language="javascript">
<!--

function reset() {
document.Form1.FirstName.value="";
document.Form1.LastName.value="";
document.Form1.Email.value="";
document.Form1.RName.value="";
document.Form1.Schemes.value="";
document.Form1.colors.value="";
}

function validate() {


if (document.Form1.FirstName.value.length==0) {
alert("Please enter your first name!");
return false;
}

if (document.Form1.LastName.value.length==0) {
alert("Please enter your last name!");
return false;
}

if (document.Form1.Email.value.length==0) {
alert("Please enter a valid e-mail address!");
return false;
}

if (document.Form1.RName.value.length==0) {
alert("Please enter your restaurant's name!");
return false;
}



if (document.Form1.Schemes.value.length==0) {
alert("Please choose an option that describes your site's ideal look!");
return false;
}

if (document.Form1.colors.value.length==0) {
alert("Please choose a dominant color for your site's color scheme!");
return false;
}

document.Form1.submit()
return true;
}

//-->
</script>

Now I've been trying to incorporate this code in the forms made with DHE but it doesn't seem to work. I've been adding it to the Custom Code for Object but it still doesn't work.

I really really want this little script in there, it's pretty important and very, very handy. Is it just impossible to use it?

It would be nice if DHE had the option to make "required" fields.

s.dav
Site Admin

Italy
3364 Posts

Posted - 09 Feb 2009 :  09:54:34  Show Profile  Visit s.dav's Homepage  Reply with Quote
I'm working on such as feature for the next release; I always make forms using manual validation and all works in D.H.E.
When did you execute the "validate()" javascript function?

Please check the help under "Form Object", such as validation function MUST be executed in the "Form-Submit" event and if you want to block the submit you have to simply return false from that function.

So in D.H.E. select your form, go to Events, add the "Submit" event and in the "Javascript Call" write "return validate();"
Place a button into that form and transform it into a "Submit" button using properties.
Obviously you have to add the javascript code into your page in the Head section.

Regards, Davide
Go to Top of Page

anima3
Expert

Canada
96 Posts

Posted - 09 Feb 2009 :  14:27:35  Show Profile  Visit anima3's Homepage  Reply with Quote
Thanks, it works now!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Hexagora Forum © s.dav Go To Top Of Page
Snitz Forums 2000