Yii Framework Forum: javascript - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

javascript Rate Topic: -----

#1 User is offline   kitty10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 139
  • Joined: 13-April 10

Posted 10 May 2010 - 10:21 AM

I have to insert in the view page a function javascript to control if the data that i insert is an integer because in my db data as number,fax telephone not are integer but varchar2(oracle db)
this is my function
function checkNumbers(e) {
	var key;
	var keychar;
	var myregexp = /^[0-9]+$/;
	
	if (window.event) key = window.event.keyCode;
	else if (e) key = e.which;
	else return true;
	
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) return true;
	
	else if ( myregexp.test(keychar) ) return true;
	
	else return false;
    
}


and the event is
onkeypress="return checkNumbers(event)

Can you help me????
0

#2 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 13 May 2010 - 05:11 AM

Don't do with javascript, simpy change the rule of the model.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users