Hi friends, i need to write validation for textbox(Usernme ) which should accept only alphabets. I am able throw validation that Please fill the UserName Details.Now it should throw that it accepts only alphabets.My code goes like this::
Please can anybody tellme how to write validations for this username that it should accept only Alphabets.
Regards,
meeanji
Code:
<tr>
<td style="width:30%" align="right">User Name :</td>
<td style="width:70%"> <input name="username" size="20" maxlength="155" value="<?php echo $username;?>" onfocus="setVisibility('100','inline')"; onBlur="setVisibility('100','none')"> </td>
</tr>
<tr>
<td align="right">Password :</td>
<td> <input name="password" type="password" size="20" maxlength="155" value="<?php echo $password;?>" onfocus="setVisibility('100','inline')"; onBlur="setVisibility('100','none')"> </td>
</tr>
<script type="text/javascript">
function validate_form ( )
{
valid = true;
if ( document.msgform.username.value == "" )
{
alert ( "Please fill the UserName Details." );
valid = false;
}
else if(document.msgform.password.value == "")
{
alert ( "Please fill the Password Details." );
valid = false;
}
return valid;
}
<td>
<td> <input type="submit" name="submit" value="Submit" onClick="return validate_form();"></td></div>
</td>
</script>
Regards,
meeanji
Comment