Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: postitive list of chars? for answers?

postitive list of chars? for answers? 2 years 9 months ago #66996

Hallo is it possible to set a list of chars that are allowed?
The behavior should be like when using the only numbers question type.
I just want to have my own list of chars that are allowed.

Thanks in advance
The administrator has disabled public write access.

Re: postitive list of chars? for answers? 2 years 9 months ago #66997

  • Eddie_V
  • Eddie_V's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 42
  • Thank you received: 2
  • Karma: 1
Regex validation.

only downside is that it validates not when the user inputs, but when he clicks on "Next"
The administrator has disabled public write access.

Re: postitive list of chars? for answers? 2 years 9 months ago #67011

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5301
  • Thank you received: 291
  • Karma: 247
More information and several examples on RegEx are available at docs.limesurvey.org/Using+regular+expres...tions+for+LimeSurvey

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: postitive list of chars? for answers? 2 years 9 months ago #67023

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4071
  • Thank you received: 748
  • Karma: 341
There is a workaround for custom masks here - docs.limesurvey.org/Workarounds%3A+Manip...vey#Text_input_masks
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: halliballi123

Aw: postitive list of chars? for answers? 2 years 9 months ago #67057

Thanks for you answers. I am quite familar with regex and the validation field. But I wanted to know if it is possible like with the only numbers question type.

The solution of tpartner sounds quite good. Is something like that planned to be included in LimeSurvey?

Regards
The administrator has disabled public write access.

Aw: postitive list of chars? for answers? 2 years 9 months ago #67066

I tested the first suggestion of tpartner and it works fine.
The only improvment I could imagine would be if this would be included in LimeSurvey to make sure it will work in future releases as well.

Thank you very much.
The administrator has disabled public write access.

Re: Aw: postitive list of chars? for answers? 2 years 9 months ago #67071

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5301
  • Thank you received: 291
  • Karma: 247
halliballi123 wrote:
I tested the first suggestion of tpartner and it works fine.
The only improvment I could imagine would be if this would be included in LimeSurvey to make sure it will work in future releases as well.

Thank you very much.
You can add this as a feature request at our feature tracker . Please describe your idea as detailed as possible and try to outline a suitable solution/implementation as well.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Aw: Re: Aw: postitive list of chars? for answers? 2 years 9 months ago #67140

Hi there,

I don't know if anybody is intersted in my solution but it works fine for me so I thougt I just post it. It is not really elegant and has at least on pitfall. (getting the id of the field) If anyone has a better solution I would apreciate it ;-) Just let me know

My solution is based on the post of tpartner using the workaround of meioMask.
1 ) First of all you have to add to your survey's template the meioMask script
2 ) then you have to add my script to the template
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
 
var fields = document.getElementsByName("myinputmaskfield");
 
for (i=0;i<fields.length;i++) {
	var question = (fields[i].parentNode.parentNode.parentNode.getElementsByTagName("TR")[1].getElementsByTagName("TD")[0].getElementsByTagName("P")[0].getElementsByTagName("INPUT")[0]);
	var fieldname = question.name;
	var fieldvalue = fields[i].value;
 
		//alert(fieldname + ":" +fieldvalue);
		// Set the 'alt' attributes of the inputs
		$('#answer'+fieldname).attr('alt', fieldvalue); // a pre-defined mask		
		// Tell the plugin to apply masks to these inputs
		$('input:#answer' + fieldname).setMask();
	}
});
</script>


3 ) now you can use in your helptext (in code view) something like this:
<input type="hidden" name="myinputmaskfield" value="decimal" />

I guess other tags are also possible.
The value attribute contains the desired mask. Of course you also can define your own input masks like it is described in the workarounds page.

This solution only works for questiontype short answer. And if the design of the questiontype changes, getting the input field has to be modified.

If the question help text would have the id of the question as an attribute, this would be much easier and would also work for other question types. Then you just needed to get the parent element of the hidden input field and get the question id attribute.

Hope this helps
Regards

By the way. In the workaround page, there is an error in the example. In the code
$('input:answer111111X22XAA').setMask();
there is a # missing in front of answer
Last Edit: 2 years 9 months ago by halliballi123.
The administrator has disabled public write access.

Re: Aw: Re: Aw: postitive list of chars? for answers? 2 years 9 months ago #67141

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5301
  • Thank you received: 291
  • Karma: 247
Please add this below the workaround tpartner has linked above so other users will benefit from your solution as well.

Thanks!

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Aw: Re: Aw: Re: Aw: postitive list of chars? for answers? 2 years 9 months ago #67147

ok, i put it to the comments, can you please check, if the code is displayed correctly
thanks
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.320 seconds
Donation Image