RES: [PHP-DB] input field validation

[email protected] ("Thiago Pojda")
Newsgroups php.db
Message-ID <018601c8b44b$51ea0fe0$0201a8c0@softpartech>
It'd be simpler to use isNaN()



Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[email protected]
Excelência em Softwares Financeiros


-----Mensagem original-----
De: sahabettin akca [mailto:[email protected]] 
Enviada em: domingo, 11 de maio de 2008 14:31
Para: [email protected]
Assunto: Re: [PHP-DB] input field validation

hi,

*javascript function :

function isNumber(obj) {
	var len  = obj.value.length;
	var lastChar = obj.value.charAt(len-1);
	if( lastChar != '0' && lastChar != '1' && lastChar != '2' &&
lastChar
!= '3' && lastChar != '4' &&


	lastChar != '5' && lastChar != '6' && lastChar != '7' && lastChar !=
'8' && lastChar != '9' ) {
		obj.value = obj.value.substring(0, len-1);

	}

}

this is function use :
<input *onKeyUp='isNumber(this)' .... />

do not alert , but add alert
----
*		obj.value = obj.value.substring(0, len-1);
---
this line before

---
alert('this field only integer!');
*

----

add.
good luck
?ahabettin akca (saho)
2008/5/11 arafat uddin <[email protected]>:
-------------------------
and
this database field data type select int (integer) ,
tinyint, int, bigint... or
if(gettype($_POST['field'])!="integer") // or if(intval($_POST['field'])==0)
or if(!intval($_POST['field']))
{
print"not integer";
location("header: xxxx.php");
#or
print"<meta http-equiv='refresh' content='0;url=xxxx.php'>";
}
else
{
....
}
2008/5/11 Yves Sucaet <[email protected]>:

> Allow me to point out that this is not database-related...
>
> This website should get you everything you want:
> http://www.acmesoffware.com/acme/ExamplesJS/jsExm_ValidateInteger.asp
>
> HTH,
>
> Yves
>
> ----- Original Message ----- From: "arafat uddin" <[email protected]>
> To: <[email protected]>
> Sent: Sunday, May 11, 2008 12:48 AM
> Subject: [PHP-DB] input field validation
>
>
>
>  hi,
> >  i want to input only integer in my field.if without integer any
> > input put in the field it will show warning messege.
> > such as "12 "will be accept
> > but "12sds" will not accept .
> > "fhe34" will not accept
> >
> >
> > plz help me by any javascript code.
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
?ahabettin akca // saho
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.