Check out the LimeSurvey source code on GitHub!

Javascript field validation broken after upgrading to Build 10951

More
5 years 4 months ago #66695 by lister171254
I put the following code after the help text and it worked in 1.91 Build 10746, but doesn't work in Build 10951. Could it have something to do with the fact that formatting is automatically added to any text added into editor?

Javascript
<script type="text/javascript" charset="utf-8">

$(document).ready(function() {


var msg = 'The height must be between 45 and 250. Please re-enter it';

$('#answer{SGQ}').change(function(){
if($(this).val() && ($(this).val() < 45 || $(this).val() > 250)) {
alert (msg);
$(this).val('');
}
});
});

</script>


Resulting Page Source

<div class="survey-question-help"><img src=' epiq.register4.org.au/limesurvey/upload/...Register4V1/help.png ' alt='Help' align='left' /><p>
The Height has to be between 45 and 2500cm</p>
<p>
<script type="text/javascript" charset="utf-8"><br />
<br />
$(document).ready(function() {<br />
<br />
var msg = 'The height must be between 45 and 250. Please re-enter it';<br />
<br />
$('#answer45991X1X681').change(function(){<br />
if($(this).val() && ($(this).val() < 45 || $(this).val() > 250)) {<br />
alert (msg);<br />
$(this).val('');<br />
}<br />
});<br />
});<br />
<br />
</script></p>

</div>
</div>
<div class="survey-question-space"></div>
</div>
<input type='hidden' name='lastgroup' value='45991X1' id='lastgroup' />

Please Log in to join the conversation.

More
5 years 4 months ago #66698 by Mazi
1. Did you adjust IDs if those changed because of import/export?

2. Did you add the Javascript in source code mode?


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 4 months ago #66726 by lister171254
As to item 1)

I thought that "answer{SGQ}" takes care of IDs. The generated source [($('#answer45991X1X681').change(function()]certainly looks like the correct.

As to Item 2), I had the Inline Editor enabled. I have now changed this to the default editor and everything works ok now

Please Log in to join the conversation.

More
5 years 4 months ago #66728 by Mazi

lister171254 wrote: As to Item 2), I had the Inline Editor enabled. I have now changed this to the default editor and everything works ok now

You're welcome!

If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.

Without your help we can't keep this project alive.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form