Welcome, Guest
Username: Password: Remember me

TOPIC: Javascript field validation broken after upgrading to Build 10951

Javascript field validation broken after upgrading to Build 10951 2 years 6 months ago #66695

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' />

The administrator has disabled public write access.

Re: Javascript field validation broken after upgrading to Build 10951 2 years 6 months ago #66698

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5279
  • Thank you received: 289
  • Karma: 246
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)limesurvey.org'"
The administrator has disabled public write access.

Re: Javascript field validation broken after upgrading to Build 10951 2 years 6 months ago #66726

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
The administrator has disabled public write access.

Re: Javascript field validation broken after upgrading to Build 10951 2 years 6 months ago #66728

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5279
  • Thank you received: 289
  • Karma: 246
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)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.113 seconds
Donation Image