• 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: Display Validation messages at top of form?

Display Validation messages at top of form? 17 years 2 months ago #1929

  • Trisoft
  • Trisoft's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hi!

I just started using RSForm and it works great! I have a rather long form with a lot of fields that are all required. The problem is that when the submit button is pressed, the form just displays again and you have to scroll quite a bit to find out what field that was not filled in. For a novice user it would be unclear if the form was submitted or not.

I would like to display all the validation messages that got triggered at the top of the form to help the user find the fields that needs to be corrected.

Is there a simple way to do this, like adding {errormessages} or {validationmessages} in the \"form style\" or should I just hack the php and display it myself?

I am using Joomla 1.5 stable and RSForm 1.0.4.

Best regards
Lars<br><br>Post edited by: Trisoft, at: 2008/02/14 12:41
The administrator has disabled public write access.

Re:Display Validation messages at top of form? 17 years 1 month ago #2475

...or a way to get the page to scroll to the right spot? My form isn't that long, but I'm using the mosforme plugin to put the form at the bottom of an article page, so I have the same concern, that a novice won't know that if they don't see a thank you message the form didn't go through yet. Either solution would be fine with me:
  • put the message(s) at the top of the page
  • put an anchor at each field and if validation fails include the anchor of the first failed field in the URL
Anyone out there have a suggestion for Lars and me, other than hacking the code? I am using the same versions as Lars.

Karen
The administrator has disabled public write access.

Re:Display Validation messages at top of form? 16 years 6 months ago #5485

I have displayed a validation message at the top of my form by using the following code in the manage forms > scripts > Script called on form display:
if(isset($_POST['form'])) echo \&quot;type your top of page validation message here!\&quot;;

Hope this helps...

Jen
The administrator has disabled public write access.

Re:Display Validation messages at top of form? 16 years 6 months ago #5492

Jen, that's fine if one is doing all field validation by hand in the script (I assume your example is just an extreme simplification of hand-coded validation - a single piece of text that always appears when the form is submitted is not what Lars and I are calling field validation). But RSForm has optional validation built into the setup of each field, and it is those messages that we're trying to figure out how to get to appear at the top.

Lars, did you ever figure it out?
The administrator has disabled public write access.

Re:Display Validation messages at top of form? 16 years 6 months ago #5510

Fair enough. I found it useful to have the field validations under the field they referred to, and to have a message at the top saying something like \"Your form does not appear to be completed. Please scroll down and look for the error messages in red and try again\".

A possible quick way to move the validation messages to the top would be to use CSS...
.formError {
position:absolute;
top:0;
}

Of course if there was more than one error they would overlap (although you could use the span id to shift each validation message up or down separately so they don't), could work for a small form...but probably wouldn't be ideal for a long one!

Jen
The administrator has disabled public write access.

Re:Display Validation messages at top of form? 16 years 6 months ago #5512

Oh, I get what you mean now! The first time I read your first post I missed the subtlety of \"Script called on form display\" - if one puts the code you suggested in the Script called on form process\" (which is what I was thinking you were talking about), it would show every time the user submitted, whether they passed validation or not (that's why I thought it was just a stub for more conditionals to check the data). But if a check of $_POST is placed in the form display script, provided that on form submission the same stream of execution continues to the point of displaying the form again when needed, $_POST would still be set, so the message would appear when (and only when) the form is redisplayed due to a validation failure. Yes, that might be enough for my purposes. The CSS suggestion would be messy and might not be able to completely avoid overlapping something - too risky. But as long as the top of the page clearly changes when they submit but end up back at the form again due to validation, I think I'd be happy with the way you do it.

I'm swamped with other projects at the moment, but I'll give it a try when I get a chance. Thanks!
The administrator has disabled public write access.

Re:Display Validation messages at top of form? 16 years 5 months ago #5838

  • dex
  • dex's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Or here's what I tried:

if(isset($_POST)) {
echo \"<script type=text/javascript>\";
echo \"window.onload=setfocus;\";
echo \"function setfocus() { \";
echo \"var focusHere = document.getElementById('Submit');\";
echo \"focusHere = focusHere.focus();\";
echo \"window.scrollBy(0,50);\";
echo \"}\";
echo \"</script>\";
}

Put this in the
The administrator has disabled public write access.

Re:Display Validation messages at top of form? 16 years 3 months ago #6432

  • dsided
  • dsided's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hmm... looks like the last bit of your message got cut off. Have you found a solution? This is a major issue. Thanks!
The administrator has disabled public write access.

Re:Display Validation messages at top of form? 16 years 2 months ago #6528

  • rhellyer
  • rhellyer's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
I am using rsformpro and have solved this problem by using the option to customise the form layout and putting all the {fieldname:validation} tags at the top of the form layout.
The administrator has disabled public write access.

Re:Display Validation messages at top of form? 14 years 6 months ago #11693

Using Joomla 1.5.20 and RSform (not Pro) I used the following code in the Scripts tab - Script called on form process box:
if (!empty($_POST['form'])) {
JError::raiseNotice(
500,
JText::_('Your form was not submitted. Please complete all required fields.')
);
}
The administrator has disabled public write access.

Re:Display Validation messages at top of form? 14 years 6 months ago #11751

  • agro355
  • agro355's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
ljjalango, you method works but in my case the message appears when the form was submited successfully too (with the thank you message). I used Your code in the Scripts tab - Script called on form process box. Please, help me, what's the problem?
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!