Yii Framework Forum: [Ask] Cara Validasi isian di client menggunakan data di server - Yii Framework Forum

Jump to content

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

[Ask] Cara Validasi isian di client menggunakan data di server Rate Topic: -----

#1 User is offline   semprul 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 10-January 12

Posted 19 January 2012 - 04:23 AM

Langsung aja ke topiknya, saya mau tanya gimana caranya bikin validasi dini di yii tp validasinya berdasarkan data yang ada di database server...
Misalnya kayak pertama kali register email (gambar di attachment)
kita masukin username yg kita mau, tp ketika diisi itu secara realtime kita bisa ngecek ke server apakah yg diinputkan di textfield itu udah ada belum di server tanpa harus refresh page.

Thx anyway.. :)

Attached File  Capture.PNG (2.41K)
Number of downloads: 20
0

#2 User is offline   ahmadroni 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 250
  • Joined: 14-June 09
  • Location:Yogyakarta-Indonesia

Posted 19 January 2012 - 11:48 PM

validasinya di buat di Model, kemudian di deklarasikan di rule contoh nih...

public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('username','authenticate','on'=>'create'),
		);
	}
	
public function authenticate()
    {
        $exist=self::model()->exists('username=:vuser',array(':vuser'=>$this->username)) ;
        if(!empty($exist))
            $this->addError('username','Username sudah digunakan..!');
    }



itu kan ngecek valitas username..kalo email tinggal ganti aja gan..!
Hospital Cost Management System and
Hospital Management Information System
0

#3 User is offline   ahmadroni 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 250
  • Joined: 14-June 09
  • Location:Yogyakarta-Indonesia

Posted 19 January 2012 - 11:50 PM

oh ya jangan lupa di view.. terutama di form dibuat ajaxvalidation=>true

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'account-form',
	'enableAjaxValidation'=>true,
)); ?>



mudah2an membantu.. jangan lupa voet nya..he..he
Hospital Cost Management System and
Hospital Management Information System
2

#4 User is offline   semprul 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 10-January 12

Posted 20 January 2012 - 04:09 AM

thx bro, btw itu harus submit dulu ya?
kalo sy mau buatnya dia ngecek ke server pas ada event onChange ke textfilednya ato ada tombol cek gitu gmn ya?
0

#5 User is offline   ressaince 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 163
  • Joined: 10-January 11
  • Location:Jakarta

Posted 21 January 2012 - 08:49 AM

pake jQuery aja gan!
untuk caranya cukup mudah dan tutorialnya banyak.
take it or leave it
0

#6 User is offline   semprul 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 10-January 12

Posted 24 January 2012 - 04:29 AM

ajaxVAlidationnya dah saya ubah jd true tp knpa ga ada perubahan ya?
ajaxnya jalan pada saat onChange ato apa ya?
soalnya ga terjadi apa, jd tetep harus klik submit button dulu baru bisa validasi.
0

#7 User is offline   angela88 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 14-October 11
  • Location:Jakarta

Posted 24 January 2012 - 04:43 AM

kalo di rulesnya cuma pake kaya gini ga bisa???
array('username', 'unique', 'on'=>'insert'),  
array('email', 'unique', 'on'=>'insert, update'),  


q pake itu berhasil soalnya...
0

#8 User is offline   semprul 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 10-January 12

Posted 24 January 2012 - 08:19 AM

Kalo masalah rulenya sih udah jalan semua, yg jadi masalah adalah gimana biar rulenya itu jalan sebelum teken tombol createnya. Sy udah cb ajaxValidation nya set jd true tp ttp ga berpengaruh, ttp harus teken tombol create dulu untuk melakukan validasi
0

#9 User is offline   pengemizt 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 21-August 11
  • Location:Jakarta, Indonesia

Posted 30 January 2012 - 12:27 PM

kalo yg ini gimana gan?

'clientOptions' => array(
	'validateOnSubmit' => true,
	'validateOnChange' => true,
),

0

#10 User is offline   ahmadroni 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 250
  • Joined: 14-June 09
  • Location:Yogyakarta-Indonesia

Posted 07 February 2012 - 11:47 PM

View Postsemprul, on 24 January 2012 - 08:19 AM, said:

Kalo masalah rulenya sih udah jalan semua, yg jadi masalah adalah gimana biar rulenya itu jalan sebelum teken tombol createnya. Sy udah cb ajaxValidation nya set jd true tp ttp ga berpengaruh, ttp harus teken tombol create dulu untuk melakukan validasi


sudah ketemu belum yang ini??
Hospital Cost Management System and
Hospital Management Information System
0

#11 User is offline   semprul 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 10-January 12

Posted 11 June 2012 - 10:58 PM

View Postahmadroni, on 07 February 2012 - 11:47 PM, said:

sudah ketemu belum yang ini??


belum ketemu bro,
jadinya ga pake begituan..
kalo boleh sharing bro disini, thx..
0

#12 User is offline   ahmadroni 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 250
  • Joined: 14-June 09
  • Location:Yogyakarta-Indonesia

Posted 15 June 2012 - 09:02 PM

kalo ajaxvalidation sudah di aktifkan maka di controller juga harus di aktifkan bagian yang
$this->performAjaxValidation($model);


Hospital Cost Management System and
Hospital Management Information System
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