If you have getters validation:
namespace Acme\DemoBundle\Entity;
class User
{
// ...
/**
* @return bool
*
* @Assert\True(message="The password cannot match your first name")
*/
public function isPasswordLegal()
{
return $this->firstName != $this->password;
}
}
then you have to create a callback:
Then you have to implement it on the JS side:
$('form#user').jsFormValidator({
callbacks: {
'isPasswordLegal': function() {
var firstName = $('#user_firstName').val();
var password = $('#user_password').val();
return firstName != password;
}
}
});
Pure Javascript:
var field = document.getElementById('user');
FpJsFormValidator.customize(field, {
callbacks: {
'isPasswordLegal': function() {
var firstName = document.getElementById('user_firstName').value;
var password = document.getElementById('user_password').value;
return firstName != password;
}
}
});