Thursday, 21 July 2016

Validate username as alphanumeric with underscores using PHP

Regular Expression is /^[A-Za-z0-9_]+$/
This allows just alphanumeric characters and the underscore.

Eg:
      if( preg_match('/^[A-Za-z0-9_]+$/', 'hello123_') )
             echo "Success";
      else
             echo "Fail";

Monday, 4 July 2016

show modal using jquery without button click

Bootstrap has a few functions that can be called manually on modals:

$('#myModal').modal('toggle');
$('#myModal').modal('show');
$('#myModal').modal('hide');

You can see more here: Bootstrap modal component
Specifically the methods section.

So you would need to change:
 
$('#my-modal').modal({
    show: 'false'
}); 

to:
 
$('#myModal').modal('show'); 

Git merge branch to another branch

$ git checkout develop $ git pull $ git checkout test-branch $ git merge develop $ git push