Forum

July 12th, 2025
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Input Mask jqGrid + PHP
05/10/2011
22:01
Avatar
verosb
Spain
Member
Members
Forum Posts: 8
Member Since:
05/10/2011
sp_UserOfflineSmall Offline

I want to create an input mask that when a phone number is entered in the phone field it is automatically formatted to (xxx)xxx-xxxx.

How can I do this?

06/10/2011
08:38
Avatar
rochiel
France
Member
Members
Forum Posts: 20
Member Since:
26/05/2010
sp_UserOfflineSmall Offline

Hello,

Are you talking about Form function ?

In this case you could use Jquery maskedinput plugin, see at :

http://digitalbush.com/project.....put-plugin

06/10/2011
11:26
Avatar
verosb
Spain
Member
Members
Forum Posts: 8
Member Since:
05/10/2011
sp_UserOfflineSmall Offline

The code of my jqgrid "grid.php" is:

CODE:

<?php
require_once '../../../jq-config.php';
// include the jqGrid Class
require_once ABSPATH."php/jqGrid.php";
// include the driver class
require_once ABSPATH."php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
//$conn->query("SET NAMES utf8");

// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = 'SELECT coddelegacion, descdelegacion, domiciliodelegacion, poblaciondelegacion, codpostaldelegacion, provinciadelegacion, telefonodelegacion, faxdelegacion, emaildelegacion FROM gestdelegaciones001';
// Set the table to where you add the data
$grid->table = 'gestdelegaciones001';
$grid->setPrimaryKeyId('coddelegacion');
$grid->serialKey = false;
// Set output format to json
$grid->dataType = 'json';

//Validacion
$checkTelefono = <<<CHECKER
function checkTel(value, colname) {
if (value.length==9)
return [true,""];
else
return [false,"El teléfono debe tener 9 dígitos"];
}
CHECKER;

// Let the grid create the model
$grid->setColModel();
$grid->setColProperty("coddelegacion", array("label"=>"Codigo", "width"=>60, "readonly"=>true, "editable"=>false));
$grid->setColProperty("descdelegacion", array("label"=>"Delegacion", "width"=>120));
$grid->setColProperty("domiciliodelegacion", array("label"=>"Domicilio", "width"=>100));
$grid->setColProperty("poblaciondelegacion", array("label"=>"Poblacion", "width"=>80));
$grid->setColProperty("provinciadelegacion", array("label"=>"Provincia", "width"=>80));
$grid->setSelect("provinciadelegacion","SELECT DISTINCT IDPROVINCIA, DESCPROVINCIA FROM gestprovin001 ORDER BY DESCPROVINCIA", true, true, false);
$grid->setColProperty("codpostaldelegacion", array("label"=>"CPostal", "width"=>70,"editrules"=>array("required"=>true, "number"=>true, "integer"=>true)));

$grid->setColProperty("telefonodelegacion", 
array("label"=>"Telefono", "width"=>90, 
"formatoptions"=>array("srcformat"=>"Y-m-d H:i:s", "newformat"=>"Y-m-d"),
"editrules"=>array
(
"required"=>true, "number"=>true, "integer"=>true, "custom"=>true, "custom_func"=>"js:".$checkTelefono
), 
"editoptions"=>array("dataInit"=>"js:function(elm){jQuery(elm).mask('(999) 999-9999');}") 
)); 
//$grid->setColProperty('telefonodelegacion',array("formoptions"=>array("rowpos"=>3,"colpos"=>2)));
$grid->setColProperty("faxdelegacion", array("label"=>"Fax", "width"=>90, "editoptions"=>array("maxlength"=>9)));
$grid->setColProperty("emaildelegacion", array("label"=>"Email", "width"=>200, "editrules"=>array("required"=>true, "email"=>true)));
// Set the url from where we obtain the data
$grid->setUrl('grid.php');
// Set some grid options
$grid->setGridOptions(array(
"rowNum"=>10,
"rowList"=>array(10,20,30),
"sortname"=>"coddelegacion",
"multiselect"=>true
));
// The primary key should be entered
$grid->setColProperty('descdelegacion', array("editrules"=>array("required"=>true)));
// Enable navigator
$grid->navigator = true;
// Enable only deleting
$grid->setNavOptions('navigator', array("csv"=>true, "pdf"=>true, "excel"=>false,"add"=>true,"edit"=>true,"del"=>true,"view"=>true, "search"=>false));
$grid->setNavOptions('edit',array("closeAfterEdit"=>true,"width"=>300,"height"=>280,"dataheight"=>220));
$grid->setNavOptions('add',array("closeAfterAdd"=>true,"width"=>300,"height"=>280,"dataheight"=>220));

//Opciones PDF
$oper = jqGridUtils::GetParam("oper");
// prevent some executions when not excel export
if($oper == "pdf") {
$grid->setPdfOptions(array(
// enable header information
"header"=>true,
// set bigger top margin
"margin_top"=>27,
//header title
"header_title"=>"e-Project",
// and a header string to print
"header_string"=>"GESTION DELEGACIONES EULEN"
));
}

$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;

?>

And i obtain the next error code:

ERROR: The object does not accept this property or method

Thank you for your help!!

07/10/2011
09:18
Avatar
rochiel
France
Member
Members
Forum Posts: 20
Member Since:
26/05/2010
sp_UserOfflineSmall Offline

Hmmmm,

I'm using Javascript Grid and developped custom PHP Grid than i think than i could help you 🙂

I suppose than you error is a javascript error.

Well,

Remove this part opf your code :


"editoptions"=>array("dataInit"=>"js:function(elm){jQuery(elm).mask('(999) 999-9999');}"

Try if you've got always your problem :

 - If not, it seems than Jquery mask plugin doesn't exist in your page, check if it's true. The code "

<script src="jquery.maskedinput.js" type="text/javascript"></script>"  need to be present 🙂

 - If true, i don't know.... :s

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
15 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information