Tuesday, June 2, 2009

Check for blank space in string using Javascript

Following is a javascript function that helps to check for a blank space in a string :

<script type="text/javascript" language="javascript">

function check()
{
var Pattern=new RegExp(" ")
var val=pattern.exec(document.getElementById("<%=TextboxID.ClientID").value)

if(val==null)
{
alert("No space found");
}
else
{
alert("Blank space not allowed")
}
}

</script>


Finally this function can be called on event on which we want to check for the blank space in the string

No comments:

Post a Comment