Enter Folder Name

Source Code

<script language="javascript">
<!--
function new_onclick()
{
//validating whether the input is blank
if (document.ContactsFolder.txtFolder.value == "")
{
    alert("Please enter a name for New Folder.");
    document.ContactsFolder.txtFolder.focus();
    return false;
}
else
{
//validating whether the input contains any space or invalid characters
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
var checkStr = document.ContactsFolder.txtFolder.value;
var allValid = true;

for (i = 0; i < checkStr.length; i++)
{
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
        if (ch == checkOK.charAt(j))
            break;

        if (j == checkOK.length)
        {
            allValid = false;
            break;
        }
}

if (!allValid)
{
    alert("Please enter only letter,digit and underscore as the new name.");
    document.ContactsFolder.txtFolder.focus();
    return false;
}
else
{
    return true;
}
}
}
//-->

</script>

<html>
<
head>
<
title>Validating Input</title>
<
/head>
<
body>

<form name="ContactsFolder">
<
p><input type="text" name="txtFolder" size="20"> <input type="submit" name="submit"
value="
ok" onClick="javascript:new_onclick()"> </p>
<
/form>

</body>
<
/html>

 

Send mail to santhosh_emids@yahoo.com with questions or comments about this web site.
Last modified: November 16, 2000