event activetextfield

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???

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

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…

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