Welcome, Guest
Username: Password: Remember me

TOPIC: help jquery function

help jquery function 1 year 11 months ago #84388

  • mattias
  • mattias's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 77
  • Karma: 1
I like that he could not move the focus if it enters the box is incorrect.
<script type="text/javascript">
$(document).ready(function(){
 
var text = 'Rut Incorrecto';	
$('#answer44855X13600X148215').Rut({
  on_error: function(){ 
 
  alert (text);
},
  format_on: 'keyup'
});
});
</script>
 

joaquinnunez.cl/jQueryRutPlugin/

regards
Last Edit: 1 year 11 months ago by mattias.
The administrator has disabled public write access.

Re: help jquery function 1 year 11 months ago #84443

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4072
  • Thank you received: 748
  • Karma: 341
Are you trying to validate for a Chilean RUT number?

Did you install the plugin in your template directory and call it in startpage.pstpl?

Any JavaScript errors?
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.

Re: help jquery function 1 year 11 months ago #84472

  • mattias
  • mattias's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 77
  • Karma: 1
tony,

yes of course, i can validate chilean rut number use limesurvey , install the plugins and it work , but the idea is Chilean rut is invalid if it can´t go to the other text box.
<script type="text/javascript" src="{TEMPLATEURL}jquery.Rut.js"></script>
<script type="text/javascript" src="{TEMPLATEURL}jquery.Rut.min.js"></script>

regards
The administrator has disabled public write access.

Re: help jquery function 1 year 11 months ago #84474

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4072
  • Thank you received: 748
  • Karma: 341
You only need to call one of those scripts. All you need in startpage.pstpl is:
<script type="text/javascript" src="{TEMPLATEURL}jquery.Rut.min.js"></script>


I would handle this as follows:

1) Change the plugin event to "change"
2) Disable all other text inputs on the page
3) If the RUT validation fails, alert the respondent
4) If the RUT validation passes, enable the other text inputs
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		var text = 'Rut Incorrecto';
		var rutInput = $('#answer44855X13600X148215');
 
		$('input.text').attr('disabled', true);
		$(rutInput).attr('disabled', false);
 
		$(rutInput).Rut({
			on_error: function(){
				$('input.text').attr('disabled', true);
				$(rutInput).attr('disabled', false); 		 
				alert (text);
			},
			on_success: function(){ 		 
				$('input.text').attr('disabled', false);
			},
			format_on: 'change'
		});
 
	});
 
</script>
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.
Last Edit: 1 year 11 months ago by tpartner.
The administrator has disabled public write access.

Re: help jquery function 1 year 11 months ago #84476

  • mattias
  • mattias's Avatar
  • OFFLINE
  • Senior Lime
  • Posts: 77
  • Karma: 1
thank you, it worked perfect.

cheers !!
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.130 seconds
Donation Image