Tuesday, July 6, 2010

Only Numeric Value Allow In TextBox in JavaScript


function funi(t) {

//var t=document.getElementById(r);
if (!(t.keyCode >= 48 && t.keyCode <= 57)) {
t.keyCode = 0;
}
}

Call this like following

<input type="text" onkeypress="funi(event)"></input>

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. class frnd_request
    {
    function user_request($uid)
    {
    $user_req = mysql_query("select no_of_req from admin_frnd_req");
    $req = mysql_fetch_array($user_req);
    $date = date('Y-m-d');
    $no_of_req="select * from requests where from_id='".$uid."' and r_date='".$date."'";
    $result = mysql_query($no_of_req);
    $count=mysql_num_rows($result);
    if($req['no_of_req'] > $count)
    {
    echo "not a valid request";
    }
    }
    }

    ReplyDelete