Trim Function using java script.Validation for text box if there only space using java script.validation for space in text box using java script.
Solution:
Create A textbox with id txtname and a button id btntest and wite this function inside script tag.
function trim(string)
{
var a = string.replace(/^\s+/, '');
return a.replace(/\s+$/, '')
}
function TestTrim()
{
x = window.document.getElementById("txtname");
str="Please Enter User Name";
if (trim(x.value)=="")
{
alert(str);
x.select();
x.focus();
return false ;
}
}
And then call the function on c#(code behind page)
btntest.Attributes.Add("onclick", "return TestTrim();");
Sunday, January 11, 2009
Subscribe to:
Post Comments (Atom)
1 comment:
Really this javascript function is help me..
thank you so much
Post a Comment