vcxz_1982
(378619801)
1
Hi all!
I want to use TAB key down repeal Enter event In ActiveForm, normal use this code.
<script language="javascript" for="document" event="onkeydown">
<!--
if(event.keyCode==13 && event.srcElement.type!='button' && event.srcElement.type!='submit')
{
event.keyCode=9;
return true;
}
-->
</script>
But I insert this code into main.php, It’s can’t work.
I think the problem caused by JQuery js.
Thanks!
Asgaroth
(Asgaroth Belem)
2
What its not working exactly? please describe your problem in more detail.
What does firebug says? any errors there?
normal: if I press Enter key, the focus go to next input.
but In Yii , can’t goto next input, it’s do submit when press enter key.
Asgaroth
(Asgaroth Belem)
4
Well I never saw this syntax before:
<script language="javascript" for="document" event="onkeydown">
Can you try something like this and see if it works instead?
<script type="text/javascript">
$('$myform input').keydown(function(event){
if(event.keyCode==13 && event.srcElement.type!='button' && event.srcElement.type!='submit')
{
event.keyCode=9;
return true;
}
});
</script>
Are you sure that just changing the keyCode would have any effect?
Yes, It’s no any effect.
My code. (IE9)
<div class="wide form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'client-account-form',
'enableAjaxValidation'=>false,
)); ?>
<script type="text/javascript">
$('$client-account-form input').keydown(function(event){
alert("");
if(event.keyCode==13 && event.srcElement.type!='button' && event.srcElement.type!='submit')
{
event.keyCode=9;
return true;
}
});
</script>