Check Password Strength in Jquery


$('#pass').keyup(function(e) {
     var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\W).*$", "g");
     var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
     var enoughRegex = new RegExp("(?=.{6,}).*", "g");
     if (false == enoughRegex.test($(this).val())) {
             $('#passstrength').html('More Characters');
     } else if (strongRegex.test($(this).val())) {
             $('#passstrength').className = 'ok';
     } else if (mediumRegex.test($(this).val())) {
             $('#passstrength').className = 'alert';
     } else {
             $('#passstrength').className = 'error';
     return true;
By Sriramjithendra Posted in Jquery

Facade Pattern.

The Facade pattern is a common software design pattern used to create a simple unified interface for a set of interfaces in a system. The Facade interface is a higher-level interface that allows easier control of a set of subsystem interfaces without affecting the subsystem interfaces.The Facade pattern encourages composition over inheritance, and is a good way to clean up and simply a set of complex subsystems into one more simple, higher-level interface. Continue reading

What is difference between First and FirstOrDefault in LINQ?


.First() will throw an exception if there’s no row to be returned, while .FirstOfDefault() will return a NULL value instead. .FirstOfDefault() will simply return either null (reference types) or the default value of the value type. (e.g like ‘0’ for an int.) .FirstOfDefault() is preferred when you’re not sure if you’re going to get results out of your query. When logically the data should be there, exception handling can be considered. Between .First() and  .FirstOfDefault(), you should use .First() when you’re sure that an element exists and if it doesn’t, then there’s an error.

someList.First(); // exception if collection is empty.
someList.FirstOrDefault(); // first item or default(Type)









  • Returns the first element of a sequence
  • Throws exception: There are no elements in the result
  • Use when: When more than 1 element is expected and you want only the first