This topic is locked

Validation on Drop Down box

1/11/2011 8:04:14 PM
PHPRunner General questions
J
jeffrey404 author

Hello,
I am testing out phprunner (by the way, the best I have tried so far) and I am stuck on how to implement a validation check. Here is what I am trying to do.
On the add page, I have a list of domains that the user can select from (based on the correct ownerid useing the where function in lookup wizard). They choose a domain from the drop down and enter an IP address in the box below it.
What I want to verify is that the email address they entered is part of the domain they chose. so if they chose example.com, they email address should be anything@example.com and not allow anything@example.org or etc.
Any suggestions would be great.
Thanks in advance.
Jeff

romaldus 1/11/2011



Hello,
I am testing out phprunner (by the way, the best I have tried so far) and I am stuck on how to implement a validation check. Here is what I am trying to do.
On the add page, I have a list of domains that the user can select from (based on the correct ownerid useing the where function in lookup wizard). They choose a domain from the drop down and enter an IP address in the box below it.
What I want to verify is that the email address they entered is part of the domain they chose. so if they chose example.com, they email address should be anything@example.com and not allow anything@example.org or etc.
Any suggestions would be great.
Thanks in advance.
Jeff


This is very easy to do. Just utilize dependent dropdown in your PHPRUNNER project.

To do this you must first design your database like this:



DOMAIN_TABLE


(Integer, Auto Increment, Not Null) -----------------------> this is the primary key

[color="#ff0000"]domain_name (char, 20)
EMAIL_ADDRESS_TABLE

(Integer, Auto Increment, Not Null)

[color="#ff0000"]domain_id (Integer) -----------------------> this is the foreign key from DOMAIN_TABLE

(char, 30)
ANOTHER_TABLE (this is your problem)

[color="#ff0000"]another_table_id (Integer, Auto Increment, Not Null)
[color="#ff0000"]email_id (integer) -----------------> dependent dropdown to select email adreess from EMAIL_ADDRESS_TABLE
on you your phprunner project, configure the ANOTHER TABLE email_id field to use lookup wizard and set the dependent dropdown: choose both domain_id for both category control & category field

romaldus 1/11/2011



Hello,
I am testing out phprunner (by the way, the best I have tried so far) and I am stuck on how to implement a validation check. Here is what I am trying to do.
On the add page, I have a list of domains that the user can select from (based on the correct ownerid useing the where function in lookup wizard). They choose a domain from the drop down and enter an IP address in the box below it.
What I want to verify is that the email address they entered is part of the domain they chose. so if they chose example.com, they email address should be anything@example.com and not allow anything@example.org or etc.
Any suggestions would be great.
Thanks in advance.
Jeff


This is very easy to do. Just utilize dependent dropdown in your PHPRUNNER project.

To do this you must first design your database like this:



DOMAIN_TABLE


(Integer, Auto Increment, Not Null) -----------------------> this is the primary key

[color="#ff0000"]domain_name (char, 20)
EMAIL_ADDRESS_TABLE

(Integer, Auto Increment, Not Null)

[color="#ff0000"]domain_id (Integer) -----------------------> this is the foreign key from DOMAIN_TABLE

(char, 30)
ANOTHER_TABLE (this is your problem)

[color="#ff0000"]another_table_id (Integer, Auto Increment, Not Null)
[color="#ff0000"]email_id (integer) -----------------> dependent dropdown to select email adreess from EMAIL_ADDRESS_TABLE
on you your phprunner project, configure the ANOTHER TABLE email_id field to use lookup wizard and set the dependent dropdown: choose both domain_id for both category control & category field

Sergey Kornilov admin 1/11/2011

The first suggestion is to make user enter the left part of email address only i.e.

[name input box]@[domain dropdown box]
If this doesn't work for you create a Javascript validation plugin and apply it to email field. In this plugin you can read dropdown control value and verify the domain.
Create file named EmailDomain.js in C:\Program Files\PHPRunner5.3\source\include\validate directory and paste the following sample code there. Modify it according to your needs.

function EmailDomain(sVal)

{

var ctrl = Runner.getControl(1, 'Make');

var value = ctrl.getValue();

if (value=='Audi')

return 'You can choose anything but Audi';

else

return true;

}


You can use either plain Javascript/jQuery there or, per this example, Javascript API. Since pageid is not passed to validation routine you can use the hardcoded value of 1 there.
Hope this helps.

J
jeffrey404 author 1/12/2011



The first suggestion is to make user enter the left part of email address only i.e.

[name input box]@[domain dropdown box]
If this doesn't work for you create a Javascript validation plugin and apply it to email field. In this plugin you can read dropdown control value and verify the domain.
Create file named EmailDomain.js in C:\Program Files\PHPRunner5.3\source\include\validate directory and paste the following sample code there. Modify it according to your needs.

function EmailDomain(sVal)

{

var ctrl = Runner.getControl(1, 'Make');

var value = ctrl.getValue();

if (value=='Audi')

return 'You can choose anything but Audi';

else

return true;

}


You can use either plain Javascript/jQuery there or, per this example, Javascript API. Since pageid is not passed to validation routine you can use the hardcoded value of 1 there.
Hope this helps.


Sergey,
I like the dropdown and just enter username solution. The problem is I do not know how to make it so the entry is updated in the db as a single field and not 2 fields.

Sergey Kornilov admin 1/12/2011

The easiest approach is to use BeforeAdd event. Here is the sample code:

$values["username"] = $values["username"] . '@' . $values["domain"];
J
jeffrey404 author 1/12/2011



The easiest approach is to use BeforeAdd event. Here is the sample code:

$values["username"] = $values["username"] . '@' . $values["domain"];



Ok. Thanks. I am seeing it added now. The only issue I run in to is that I pull the domain dropdown via a link to the id of the domain table. When I add the address, it only parses everything before the @ symbol.
As you can tell, I am not proficient with sql and php. Thats why I am looking at a program like phprunner.
Thanks in advance.
Jeff

Sergey Kornilov admin 1/12/2011

Jeff,
I guess we need to see your project and database to answer this question. I recommend to post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

J
jeffrey404 author 1/13/2011



Jeff,
I guess we need to see your project and database to answer this question. I recommend to post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.


Thanks,
Are we allowed to post to the demo account as a trial user? Just wondering since i am evaluating the software and want to give it the run thru. Made the mistake of buying dbqwiksite before I really tried it out.
Jeff

Sergey Kornilov admin 1/13/2011

Yes, you do. This is a totally free service designed for testing and troubleshooting purposes.

J
jeffrey404 author 1/13/2011



Yes, you do. This is a totally free service designed for testing and troubleshooting purposes.


Ok Thanks!!
I will upload and open a support ticket.