I am having a text box . I have to restrict user from entering multiple space in the beginning of the text box.
eg:
1.abc d e (Should allow)
2.$$$abc(Should not allow.Here $ I have put to represent space character)
And also should also validate if the user is entering space character only(multiple times also)
Please help me how to resolve this using jquery.
Restrict multiple entry of space
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Amit Thorat36 reputationPosted Jun 18, 2014, 2:01 AM EDT
please refer to the link
http://stackoverflow.com/questions/2809311/how-to-prevent-user-to-enter-space-at-the-
beginning-in-textbox
Sunny SharmaRank #223 · 11.1K reputationPosted Jun 18, 2014, 2:34 AM EDT
$(document).ready(function(){
$('#name').on('keydown',function(e){
$('.msg').text('');
var $name = $(this).val();
if(e.keyCode==32 & $name[$name.length-1]==' ')
{
$('.msg').text('Multiple spaces not allowed!');
return false;
}
});
})
Replace the IDs of textbox and div to per yours and you're good to go.
Refer to this sample fiddle if you need a demo:
http://jsfiddle.net/sunnykumar08/Cx6DH/
Happy Learning :)