Return to Snippet

Revision: 53702
at December 1, 2011 09:08 by xmaestro


Initial Code
//Javascript//

function validateAsYouType(inputElementId)
{
	var val=inputElementId.value;
	var lastLetter=val.substring((val.length-1),val.length);
	
	if(isNaN(lastLetter))
	{
		//Input is OK. Let things be as they are.
	}
	
	else
	{
	   //Input is not OK. Rmove the last entered character
	   
	   var new_val=val.substr(0,val.length-1);
	   document.getElementById('inputtype').value=new_val;
	   
	}
	
}

//Javascript//


Sample usage:

<input type="text" value="" id="inputtype" onkeyup="return validateAsYouType(this);" />

Initial URL

                                

Initial Description
Javascript : Validate As You Type

Initial Title
Javascript : Validate As You Type

Initial Tags

                                

Initial Language
JavaScript