Input placeholder return value

kko 28 Oct, 2010
Hi,

I am using the placeholder input parameter in my form. However, if a user does not fill out the field, the placeholder is returned. How do I get the field to return a blank/empty value if a user does not fill out that field?

Any help is appreciated.
GreyHead 29 Oct, 2010
Hi kko,

Check for the placeholder value after submission and delete it if it is found.

Bob
kko 29 Oct, 2010
Hi Bob,

Can you post the php code for doing something like that?
I know essentially it's something like: if [fieldname] == [placeholder] then return ''

I don't know php well enough to write it all out correctly. 😟
GreyHead 29 Oct, 2010
Hi kko,

In the OnSubmit Before box
<?php
$input_name = JRequest::getVar('input_string', '', 'post');
if ( $input_name == 'place_holder' ) {
  $input_name = '';
}
JRequest::setVar('input_name', $input_name);
?>
There are other ways but this should do it.

Bob
kko 29 Oct, 2010
Bob,

Thank you so much for the help. The code does what I want it to do.

Now the issue is that validation does not seem to work with input placeholders. :?
kko 29 Oct, 2010
Any ideas for a solution/workaround to have validation work with input placeholders?
GreyHead 30 Oct, 2010
Hi kko,

Yes, you need JavaScript to manage the placeholders. I wrote a script a while ago (I think it's in the forums here somewhere).

I've now written the code up and bundled it with an example form. You can see a demo here and get the document and the example form for $5 here.

Bob
colemjosel 19 Nov, 2012
Hi bob

I bought ChronoForms v4 placeholder labels but it doesnt work with date/time picker, with 2 or more forms and pass the validation for Alpha.

How can i fix this errors
GreyHead 19 Nov, 2012
Hi colemjosel,

I don't think I've tested with a date-picker. I'll take a look at that. The Alpha validation should be OK. I don't know about two forms on the page; I think that should work provided that the input IDs are all unique.

Please post a link to the form so I can take a quick look.

Bob
GreyHead 20 Nov, 2012
Hi colemjosel,

I'm not clear why the Alpha validation isn't working. It may be because you are not loading the MooTools More library on the page.

The Date & Time Picker won't work because the standard datepicker creates a copy of the input and moves the original one off the page so the Placeholder labels tries to update the hidden copy. You could try switching to the MooTools datepicker which works differently and may accept the labels.

Bob
This topic is locked and no more replies can be posted.