Textfield value cause not work validation

  • kaposvaruniversity
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 28
  • Thank you received: 0

kaposvaruniversity created the topic: Textfield value cause not work validation

Hi! I set value in a textfield element, because I want that the value text is just appear (label is hidden) and after it's disappear when clicking. It works fine with the code like this:

function ff_nev_action(element, action)
{
switch (action)
{
case 'click':
if (element.value=='Teljes név')
{element.value=''};
break;
case 'blur':
if (element.value==''){element.value='Teljes név'};
break;
default:;
}
} // ff_nev_action

My problem is that it's just working if I add the value the same word (for example Teljes név). But this case if I want to send the form validation is not working because there is a value that I wrote there.... I think it must be work with placeholder, but I tried and not work. Just if I write value. Please help me how could I set the validation (valuenotempty) for this type element if I use this code and value text to display in the label. thanks
#235032
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 2360
  • Karma: 85
  • Thank you received: 316

mihaela replied the topic: Textfield value cause not work validation

Hello,

From what you have explained it seems that the best solution for your case is simply to use placeholder.

You wrote "I think it must be work with placeholder, but I tried and not work.".

What you need to do to use placeholder is just go to "Properties" of that textfield element and in "Placeholder" field put the wanted text. After the change don't forget to save the whole form.

Let me know whether you have set it that way.

Other than that, if you wish to keep your code as it is, I can help you write validation code that will display error message if in field "nav" the text "Teljes név" is entered.

Regards,

Mihaela
#235040
  • kaposvaruniversity
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 28
  • Thank you received: 0

kaposvaruniversity replied the topic: Textfield value cause not work validation

hi Mihaela!

Thanks for your reply. I can set the placeholder, that was my problem that if I clicked the label the word isn't hidden. But I tried write that code placeholder instead of value, and now it's working fine and not make the problem with validation because the value is empty.

I have one more question, maybe I should open a new topic? In select list I add the first raw just ;firstword; and it works fine but no way to hidden this first word when I click and the list is drop down? I know that they can't choose this because not value for this raw and validation is warning them. But if it's possible it would be nice if I could hidden this raw in the list... ?

Thank you!
#235043
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 2360
  • Karma: 85
  • Thank you received: 316

mihaela replied the topic: Textfield value cause not work validation

Hello again,

I'm glad that the placeholder did resolve the first issue in the end.

As for the select list, that isn't a default feature, but you can try to add it to your select list like follows:

In the Actionscript section of the select list element check the "Blur" and "Focus". In the code area below put the following code:
function ff_sel_action(element, action)
{
switch (action)
{
case 'focus':
jQuery("#ff_elem2052").find("option").eq(0).remove();
break;
case 'blur':
jQuery('#ff_elem2052').prepend(jQuery('<option>', {
                                value: '',
                                text: 'Choose'
                            }));
break;
default:;
}
} // ff_sel_action
NOTE: In the code above replace sel with the name of your select list element. Also, you must replace ff_elem2052 with the ID of that select list that you can get by inspecting the element.

Let me know whether this helped.

Regards,

Mihaela
#235069
The following user(s) said Thank You: kaposvaruniversity
  • kaposvaruniversity
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 28
  • Thank you received: 0

kaposvaruniversity replied the topic: Textfield value cause not work validation

Hi!

Thanks for your help! It works fine! :)

David
#235083
  • kaposvaruniversity
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 28
  • Thank you received: 0

kaposvaruniversity replied the topic: Textfield value cause not work validation

Sorry, there is a mistake. If I click first on the label, it's ok, the first word is hidden. But if I would like to change and click again, every clicking one of the list items go hidden... I attached a printscreen, because maybe I didn't set well the focus and blur... What do you think, what should be the prbolem?

Thanks!
#235085
Attachments:
Moderators: ForumSupporttomeperica
Time to create page: 0.185 seconds

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans & templates!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here