hi, i have need of some requirement that in my asp.net textbox ,i want to make it such that it shouldnot allow the blank spaces
if enter the text: computer organization in my text box
but when i store the textbox value in database it should be stored as
computerorganization
like above if any blnks r given in textbox those should be eliminated and the string should be stored without any blanks
please helpme on this
Loading
Satyapriya NayakPosted May 9, 2010, 8:53 AM
Hi Pramod Kumar,
Its very easy use Replace function show below :
'" + TextBox2.Text.Replace(" ", "") + "'
Thanks
Plz mark it if it helps you.........
Jaish MathewsPosted May 9, 2010, 9:02 AM
You can handle it inside blur event like below. This solution will take care if more than one space added.
C# - TextBox1.Attributes.Add("onblur", "handleBlur(this);");
JS -
<script language="javascript" type="text/javascript">
function handleBlur(ctrl) {
var entry = ctrl.value;
var entryArray = entry.split(" ");
var count = entryArray.length;
ctrl.value = '';
for (var index = 0; index < count; index++) {
ctrl.value = ctrl.value + entryArray[index];
}
}
script>