AnandM says:
<
script
type
=
"text/javascript"
>
$(document).ready(function () {
$('#txtNoSpaces').keyup(function () {
str = $(this).val()
str = str.replace(/\s/g, '')
$(this).val(str)
});
});
</
script
>
above code is not working for your side is because the textbox id txtNoSpaces is passed by me to the function while your id is txtUsername so your code will look like below.
<script type="text/javascript">
$(document).ready(function () {
$('#txtUsername').keyup(function () {
str = $(this).val()
str = str.replace(/\s/g, '')
$(this).val(str)
});
});
</script>