Wednesday 13 February 2013

Regex for Name validation with atleast one alpahbet(A-z)


^[a-zA-Z0-9]*[a-zA-Z]+[a-zA-Z0-9]*$

To explain: The bit in the middle square brackets (the "meat in the sandwich") matches an alphabet character.
The + after it makes sure there is at least one of these.
The other two square-bracketed expressions (the "bread in the sandwich") match alphanumeric characters.
The * after each allow any number of these.
The ^ and $ surrounding the whole thing make sure it is the whole text being looked at and not just part of it.

Tuesday 12 February 2013

Hide a button for a specific time in jquery



Code:
  
var enableSubmit = function(a) {
    $(a).removeAttr("disabled");
}

$("#submit").click(function() {
    var button = this;
    $(this).attr("disabled", true);
    setTimeout(function() { enableSubmit(button) }, 3000);
    
});
Note:Dont forget to include the jquery.js file to run this demo.