kitty10
(Martde)
May 12, 2010, 3:08pm
1
How can i put an event in an activetextfield???
I have this code:
<script type="text/javascript">
function Trim(stringa){ //Levo eventuali spazi indesiderati
reTrim=/\s+$|^\s+/g;
return stringa.replace(reTrim,"");
}
function controlla(){ // Controllo correttezza codice fiscale
var p=document.modulo.codice;
var re = /^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/;
Codice=Trim(p.value.toUpperCase());
alert(re.test(Codice));
}
</SCRIPT>
And this is the event associated
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array(onSubmit=>"controlla()")); ?>
…but not work…why???Can you help me???
cyberpol
(Cyberpol 777)
May 12, 2010, 3:38pm
2
Did you try this:
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array(onsubmit=>"js: controlla()")); ?>
Note the ‘js:’ at the onsubmit option.
tri
(tri - Tommy Riboe)
May 12, 2010, 5:39pm
3
Did you try this:
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array(onsubmit=>"js: controlla()")); ?>
Note the ‘js:’ at the onsubmit option.
Try with ‘onsubmit’ in quotes. I’m not sure about the scope of onsubmit (at least it’s a form tag event), try with ‘onclick’.
/Tommy
kitty10
(Martde)
May 13, 2010, 7:45am
4
Did you try this:
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array(onsubmit=>"js: controlla()")); ?>
Note the ‘js:’ at the onsubmit option.
does not work either: onsubmit both onclick event …
I do not understand …
and it’s as if the event behind the button is not seen…
quantico
(Liarevalo)
November 25, 2011, 6:09pm
5
you can try add the single quote ’
<?php echo CHtml::submitButton(
$model->isNewRecord ? 'Enviar' : 'Save',
array('onclick'=>"js: parent.Shadowbox.close()")
); ?>
in your case
array('onSubmit'=>"js: controlla()")); ?>
or try
array('onsubmit'=>"js: controlla()")); ?>
ref:
http://www.yiiframew .../1.1/CJuiButton