How he forced him to record in field 22 number and 2 letters

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.

How he forced him to record in field 22 number and 2 letters

Postby saleh » Sat Jan 13, 2018 4:29 pm

hello

How he forced him to record in field 22 number and 2 letters

I have a field named : ACCOUNT_NO

I would like the first two letters required : SA It does not accept non-SA
22 letters or numbers
So be like this
SA1234567890123456789012
saleh
 
Posts: 132
Joined: Mon Dec 09, 2013 11:21 pm

Re: How he forced him to record in field 22 number and 2 let

Postby saleh » Sat Jan 13, 2018 4:33 pm

I also want no more than 24
Not less than 24
saleh
 
Posts: 132
Joined: Mon Dec 09, 2013 11:21 pm

Re: How he forced him to record in field 22 number and 2 let

Postby kirondedshem » Sat Jan 13, 2018 10:15 pm

If you want to do it on client side in a way thats rsponsive to user entry, then you have to put in on onchange event of the filed and write your javascript or jquery to check as he types.

BUT the easiest way is to put the validation in row_inserting event and do your checks using php and return false when not satisfied. You can google some string operations in php and you should see fucntions like str_pos etc. Otherwise you can also use regular expressions to do your check
kirondedshem
 
Posts: 331
Joined: Sat Jan 28, 2017 7:13 pm

Re: How he forced him to record in field 22 number and 2 let

Postby saleh » Sat Jan 13, 2018 11:02 pm

Please an example
saleh
 
Posts: 132
Joined: Mon Dec 09, 2013 11:21 pm

Re: How he forced him to record in field 22 number and 2 let

Postby kirondedshem » Sun Jan 14, 2018 3:21 pm

Here is an example to impliment exactly what you want in row_inserting.

// Row Inserting event
function Row_Inserting($rsold, &$rsnew) {

// Enter your code here
// To cancel, set return value to FALSE
//substute with ACCOUNT_NO
$str_to_test = $rsnew["Trademark"];

//check if sring starts with SA
if(strpos($str_to_test, "SA") !== 0)
{
$this->CancelMessage = "String must start with SA";
return FALSE;
}
//string must be exactly 24 characters
elseif(strlen($str_to_test) != 24)
{
$this->CancelMessage = "The whole string must be exactly 24 characters";
return FALSE;
}
else
{
return TRUE;
}


}


HOT TO:ALL I DID was google for like 2 mnutes and I had these two functions with proper examples. SO if possible always try to do something on your own then come with that here so others can help you from there(it help increase your creativity to problem solving)

NOTE1: Please take some time to read some books on php s well as javascript AS SOON AS POSSIBLE b4 getting into phpmaker automations as you will ALWAYS need to do some customisations on server and cleint side and as a programmer you should be able to atleast be able to find the right code to perform a given task yourself, so if your knowledge in such areas is lacking you wont get so far. phpmaker does most of the work for you but you must be clever and creative enough to help it gear into a certain direction, prepare for a certain customisation, know where to put what code to achive a given goal etc etc.

NOTE 2:ALso read about the help file and undersatnd all available event so they can guide you on what event ot use to apply a specific logic in the right place, of course using these will still need some knowledge about the languages indicated above, so the earlier to learn them(waya from phpmaker if possible) the better.
kirondedshem
 
Posts: 331
Joined: Sat Jan 28, 2017 7:13 pm

Re: How he forced him to record in field 22 number and 2 let

Postby saleh » Sun Jan 14, 2018 9:28 pm

sir kirondedshem

100% working
Thank you very much
saleh
 
Posts: 132
Joined: Mon Dec 09, 2013 11:21 pm


Return to General Discussion (PHPMaker)