T O P I C R E V I E W |
anima3 |
Posted - 07 Feb 2009 : 16:17:31 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. |
2 L A T E S T R E P L I E S (Newest First) |
anima3 |
Posted - 09 Feb 2009 : 14:27:35 Thanks, it works now! |
s.dav |
Posted - 09 Feb 2009 : 09:54:34 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. |
|
|