RSjoomla!

My Account






Lost Password?
No account yet? Register

Newsletter Subscribe

If you would like to be one of the first people to hear about the release of our new components then make sure you have subscribed to our announcements list! We won't bug you with unnecessary stuff.




RSjoomla! Board
These forums are to discuss any RSjoomla! related questions. Please note that official support is offered via Customer Support Ticketing System only, responses in the forum are not guaranteed.
Welcome, Guest
Please Login or Register.
Lost Password?
Display Validation messages at top of form? (1 viewing)
_GEN_GOTOBOTTOM Post Reply

TOPIC: Display Validation messages at top of form?

#1929
Trisoft (User)
Fresh Boarder
Posts: 1
graphgraph
Display Validation messages at top of form? 2008/02/14 14:40 Karma: 0  
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

Post edited by: Trisoft, at: 2008/02/14 12:41
  The administrator has disabled public write access.
#2475
OsakaWebbie (User)
Junior Boarder
Posts: 45
graphgraph
Re:Display Validation messages at top of form? 2008/03/19 13:42 Karma: 1  
...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.
#5485
ayeaye.design (User)
Fresh Boarder
Posts: 2
graphgraph
Re:Display Validation messages at top of form? 2008/11/11 12:53 Karma: 0  
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:

Code:

 if(isset($_POST['form'])) echo "type your top of page validation message here!";



Hope this helps...

Jen
  The administrator has disabled public write access.
#5492
OsakaWebbie (User)
Junior Boarder
Posts: 45
graphgraph
Re:Display Validation messages at top of form? 2008/11/11 16:31 Karma: 1  
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.
#5510
ayeaye.design (User)
Fresh Boarder
Posts: 2
graphgraph
Re:Display Validation messages at top of form? 2008/11/12 15:20 Karma: 0  
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...

Code:

 .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.
#5512
OsakaWebbie (User)
Junior Boarder
Posts: 45
graphgraph
Re:Display Validation messages at top of form? 2008/11/12 17:57 Karma: 1  
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['form'] 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['form'] 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.
#5838
dex (User)
Fresh Boarder
Posts: 1
graphgraph
Re:Display Validation messages at top of form? 2008/12/04 02:32 Karma: 0  
Or here's what I tried:

if(isset($_POST['form'])) {
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 ‘Script called on form display’.

What it does is once the page has finished loading (and it can see all the fields) is puts focus on the submit button, then scrolls up a little bit so it's not jammed against the bottom of the page. In this way, you should be able to see all your form fields and error messages.

Hope this is useful to somebody!
  The administrator has disabled public write access.
_GEN_GOTOTOP Post Reply
© Copyright 2007 Best of Joomla, Powered by FireBoardget the latest posts directly to your desktop