Sep 10, 2013

Bootstrap: Automatically add asterisk symbol to detected 'required' form input field

$('input').each(function(){
   if($(this).is('[required=required]')){
    if ($(this).is('[noAsterisk]')){
    return null;
   } else {
       $(this).closest(".YourClassName").children("label").append('<font style="color:red;position:absolute;" > *</font>');
   }
   }
});

* javascript above require jQuery
with the code:
if ($(this).is('[noAsterisk]')){
     return null;
}
allow you to add exception with 'noAsterisk', where you don't require asterisk as there had 'required' html tag appended.

Sep 3, 2013

CakePHP: email validation without using model


App::uses('Validation', 'Utility');
class YourClass extends AppController{

public function email($emailInput){
$validEmail = Validation::email($emailInput);
  if(!$validEmail) {
return "error";
}
}

}



Reference Source: http://stackoverflow.com/a/8140790/1834908