help jquery function

More
4 years 7 months ago - 4 years 7 months ago #84388 by mattias01
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: 4 years 7 months ago by mattias01.

Please Log in to join the conversation.

More
4 years 7 months ago #84443 by tpartner
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.

Please Log in to join the conversation.

More
4 years 7 months ago #84472 by mattias01
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

Please Log in to join the conversation.

More
4 years 7 months ago - 4 years 7 months ago #84474 by tpartner
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.
Last Edit: 4 years 7 months ago by tpartner.

Please Log in to join the conversation.

More
4 years 7 months ago #84476 by mattias01
thank you, it worked perfect.

cheers !!

Please Log in to join the conversation.