• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Dynamic 'Required=Yes/No' or Validations on dates!

Dynamic 'Required=Yes/No' or Validations on dates! 15 years 11 months ago #3137

Hello,
This is going to be a bit tricky and thats why i will be explaining in as much detail as possible, so thank you in advance for taking the time to read.

I have a form with all kinds of fields that are hiding and showing up depending on values of other fields. lets say my form consists of the following:
EnableAge (a checkbox)
Age (a text field)
EnableDate (a checkbox)
Date (a date field)

If we place a numeric validation on the Age field, if the user had that field hidden, the validation rule will be ignored, which is great, and if the field is enabled the validation rule triggers and checks for numerics (and not null) in that field, perfect.

Now the problem comes when we deal with the date field. This field does not take any kind of validations, all it takes is the \"Required\", my problem is, if this field is disabled/hidden, and the user submits, the form would not submit because that hidden/disabled field is set to \"REQUIRED\"! Which is a wrong behaviour!

How can i do one of these two:
1. Set the required on and off dynamically from the client side, using a javascript or something.
2. Set the validations rules on a date field, since if i remove the required from this field, and place a validation rule of for example \"numeric\" things will work perfectly.

This is very important, thank you in advance for helping :)<br><br>Post edited by: adel.ammari, at: 2008/06/02 15:04
Regards,
Adel M. Ammari
http://www.x360me.com
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dates! 15 years 10 months ago #3415

I have a form with all kinds of fields that are hiding and showing up depending on values of other fields. lets say my form consists of the following:

How did you go about hiding fields and displaying upon value's of certain fields?
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dat 15 years 10 months ago #3416

Hiding fields depending on other field values

I used javascript, for example, create a function as below:
&lt; s c r i p t t y p e='t e x t / j a v a s c r i p t'&gt;
function MyFunction()
{
	if(document.getElementById('Field1').checked==true) //This code is a sample of a radio button, for other fields you could use other values, like \&quot;.value\&quot;.
	{
		document.getElementById('Field2').style.visibility = 'visible'
		document.getElementById('Field2').disabled=false
	}
	else
	{
		document.getElementById('Field2').value=\&quot;\&quot;
		document.getElementById('Field2').disabled=true
		document.getElementById('Field2').style.visibility = 'hidden'
	}
}
&lt;/ s c r i p t&gt;
To call the function when the form loads, wrap your form code with a body tag as follows:
&lt;body onload=\&quot;MyFunction()\&quot;&gt;
&lt;form....&gt;
.
.
.
&lt;/form&gt;
&lt;/body&gt;
To call the function when the status of \"Field1\" changes, simple add the below in the field's header IF using basic HTML, but in RSForms you can add this on the additional values property on any field. In our example, \"Field1\"
onclick=\&quot;MyFunction()\&quot;

Hope i answered your question :)

Wish Alex would solve \"MY\" issues, the client wants to go live and the form is still not done! :(

Cheers :silly:<br><br>Post edited by: adel.ammari, at: 2008/06/19 22:34
Regards,
Adel M. Ammari
http://www.x360me.com
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dat 15 years 10 months ago #3419

Thanks for that info. I'm having a hard time figuring out where to put the javascript code though....
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dat 15 years 10 months ago #3435

In the form style, 1st remove the check on the AutoGenerate code, and then paste your javascript block on the top. before the <form> block, and ur good to go :)
Regards,
Adel M. Ammari
http://www.x360me.com
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dat 15 years 10 months ago #3501

Can you please give us more details for procedure?

I can't figure it out.... :blush:


Rune
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dates! 15 years 10 months ago #3508

Follow the instructions below:
1. Login to your website's back-end
2. Point your mouse over \"Components\" then select \"RSForm!Pro\"
3. In the new window, select \"Manage Forms\"
4. Select your form on which you want to add your script on
5. Select the tab \"Form Layout\"
6. You shold notice four kinds of preinstalled layouts:
a. Inline
b. 2 Lines
c. 2 Columns inline
d. 2 Columns 2 lines
7. If you click any of these, the code for these layouts will be autogenerated below, this is what we DO NOT WANT TO HAPPEN! So, after selecting the layout you are happy with. do the following:
8. Remove the checkbox labeled with \"Auto Generate Layout?\"
9. This will allow you to create your own style, and anything else you might want to add.
10. Since the text area below is now editable, simply enter your script block on top of the form style code.
11. Save your form.
12. Be happy.
13. Wish for Germany to win today's Match :)
14. Have a wonderful day.

Hope this helps you.
Cheers
Regards,
Adel M. Ammari
http://www.x360me.com
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dates! 15 years 10 months ago #3509

Follow the instructions below:
1. Login to your website's back-end
2. Point your mouse over \"Components\" then select \"RSForm!Pro\"
3. In the new window, select \"Manage Forms\"
4. Select your form on which you want to add your script on
5. Select the tab \"Form Layout\"
6. You shold notice four kinds of preinstalled layouts:
a. Inline
b. 2 Lines
c. 2 Columns inline
d. 2 Columns 2 lines
7. If you click any of these, the code for these layouts will be autogenerated below, this is what we DO NOT WANT TO HAPPEN! So, after selecting the layout you are happy with. do the following:
8. Remove the checkbox labeled with \"Auto Generate Layout?\"
9. This will allow you to create your own style, and anything else you might want to add.
10. Since the text area below is now editable, simply enter your script block on top of the form style code.
11. Save your form.
12. Be happy.
13. Wish for Germany to win today's Match :)
14. Have a wonderful day.

Hope this helps you.
Cheers
Regards,
Adel M. Ammari
http://www.x360me.com
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dates! 15 years 10 months ago #3517

Hello

I can't still figure this out.
is is possible for you to give some screenshoots and the code for this example you made?

Regards
RJK
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dates! 15 years 10 months ago #3522

Dear RJK,
I am sorry, but since the above step by step tutorial did not help you, i don't think i can do any more for you. Please check some books about using Joomla before you dig into using components on Joomla.

Good Luck,

Cheers :)
Regards,
Adel M. Ammari
http://www.x360me.com
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dat 15 years 9 months ago #3638

  • ljarratt
  • ljarratt's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Quick question. I am adding the javascript above and followed the other directions. For some reason I cannot save the edited form. I am doing this as admin. Any thoughts as to what might be happening?
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dat 15 years 9 months ago #3653

You say you cannot save the form, can you please explain more? do you mean that whenever you save it just does not save? like you did nothing? If so, check the write access on all the needed joomla folders. If still doesnt work, contact support, there might be some kind of bug or glitch.

If you are using the demo version, this could be it too
Regards,
Adel M. Ammari
http://www.x360me.com
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dat 15 years 9 months ago #3770

  • ljarratt
  • ljarratt's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
I am using Pro. I can now save the javascript at the top of the form except that now the javascript code itself shows up on the page. What do I need to do to correct this?
The administrator has disabled public write access.

Re:Dynamic 'Required=Yes/No' or Validations on dat 15 years 9 months ago #3786

Sounds nothing serious, this happens when you have a missing or unclosed html tags.

make sure all <blabla> have a closing </blabla>

Cheers
Regards,
Adel M. Ammari
http://www.x360me.com
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!