Hello,
I am trying to make a form where the label is a default value inside the input box. When you click or tab into the input box, the default value will clear, so you can enter your text. But if you enter nothing (ie leave the field blank) when you leave the field, it will display the default value again. I am trying to figure out where to put the JS code to do this. I tried adding a Load JS action in the Load section and putting in code to check for blu and focus events, but that didn't work. I ended up adding the onblur and onfocus events into the <input> tag like so:
The other issues, is if someone submits the form with the default value, I want to put out an error message that they need to fill in the required fields and clear out the non-required fields. Normally I would use a custom formcheck function to make the check. I would use code like this:
This all seems pretty normal functionality for forms, so there must be a way to do this. Any help on what to put where would be greatly appreciated.
Thank you for any help on this.
I am trying to make a form where the label is a default value inside the input box. When you click or tab into the input box, the default value will clear, so you can enter your text. But if you enter nothing (ie leave the field blank) when you leave the field, it will display the default value again. I am trying to figure out where to put the JS code to do this. I tried adding a Load JS action in the Load section and putting in code to check for blu and focus events, but that didn't work. I ended up adding the onblur and onfocus events into the <input> tag like so:
<input id="first_name" maxlength="150" size="30" class=" validate['required']" title="" label_over="0" hide_label="1" type="text" value="First Name *" name="first_name" onfocus="if(this.value=='First Name *')this.value='';" onblur="if(this.value=='')this.value='First Name *';" />
which is working, but not very elegant.The other issues, is if someone submits the form with the default value, I want to put out an error message that they need to fill in the required fields and clear out the non-required fields. Normally I would use a custom formcheck function to make the check. I would use code like this:
<input class=[validate'required', '%customCheck'] ... />
. But this doesn't seem to work. I added the customCheck function to the template head, but it never gets called. I also tried putting the function in the Show HTML[GS] Formcheck box, but that just stopped all validation and submitted the form.This all seems pretty normal functionality for forms, so there must be a way to do this. Any help on what to put where would be greatly appreciated.
Thank you for any help on this.
Hi raib,
I have a tutorial that you can buy here for a few $ showing how to do this in both versions of ChronoForms. It includes the code to remove any default values before form is submitted.
Bob
I have a tutorial that you can buy here for a few $ showing how to do this in both versions of ChronoForms. It includes the code to remove any default values before form is submitted.
Bob
Hi,
I have bought the tutorial. Thought that I should let you know that the sample form that you have in the tutorial doesn't work. See: http://ljkjoom.keashly.ca/index.php?option=com_chronoforms&chronoform=test_placeholder_labels. I thought you would have provided a fully functioning form.
I have copied the code provided in the tutorial and tried it in my form. All is working properly now.
Thank you.
I have bought the tutorial. Thought that I should let you know that the sample form that you have in the tutorial doesn't work. See: http://ljkjoom.keashly.ca/index.php?option=com_chronoforms&chronoform=test_placeholder_labels. I thought you would have provided a fully functioning form.
I have copied the code provided in the tutorial and tried it in my form. All is working properly now.
Thank you.
Hi rlab,
Thanks for letting me know. My apologies - I used an included file for the script and forgot to replace it :-(
I've updated the download and the revised CFv4 form backup is attached.
Bob
Thanks for letting me know. My apologies - I used an included file for the script and forgot to replace it :-(
I've updated the download and the revised CFv4 form backup is attached.
Bob
This topic is locked and no more replies can be posted.