php - I want my field to accept only integers and i have kept that field in required validation? -


this question exact duplicate of:

i have got complete project done lacking 1 requirement , i'm not able solve issue in project myself.

could use codeigniter's form validation? , set rule this:

$this->form_validation->set_rules('yourfield', 'your field\'s human name', 'required|integer'); 

this assumes field called yourfield.


after reading comments, seems want check if value in field integer using jquery. i'd suggest looking plugin: jquery - numeric

there's example of use here.

here's relevant code:

if had input this:

<input class="integer" type="text" /> 

then can validate it, checking integer, this:

$(".integer").numeric(false, function() { alert("integers only"); this.value = ""; this.focus(); }); 

however, javascript/jquery run on client-side (and can bypassed), stress important validate on server-side, in case using php. this excellent answer explains in more detail why both important.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -