Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Struts <field-validator> for email

Posted on 2010-09-23
5
Medium Priority
?
392 Views
Last Modified: 2013-11-13
Hello,

I have attached 2 validators to validate wether the user enters or leaves the email field blank and also a validator to see if is valid or not valid from the default.xml from opensymphony.

How do I add an other validator to tell me that the email already exists?  Note: im already making a DB call and already know that the email exists... Just need the actual 3rd validator.  

Please help!!!

<field name="newCompanyAdminEmail">
        <field-validator type="requiredstring">
            <message>Please enter the admin email.</message>
        </field-validator>
        <field-validator type="email">
            <message>The email address you entered is not valid.</message>
        </field-validator>
    </field>

Open in new window

0
Comment
Question by:Squadless
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 33751233
<<How do I add an other validator to tell me that the email already exists?>>
but why would you want to do it, since first validator is doing exactly the same.

may be i didn't understood the requirement, can you help?
0
 
LVL 1

Author Comment

by:Squadless
ID: 33754332
sure, the first validator checks to see if the field is blank or not, the second validator checks to see if it has a @ and a . , the third validator will check to see if the email entered by the user already exists in the database.  im making the java call and know if it exists or not, but i need to catch that action using a validator not a javascript popup.
0
 
LVL 1

Author Comment

by:Squadless
ID: 33774317
HELP
0
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 1200 total points
ID: 33775888
<<the third validator will check to see if the email entered by the user already exists in the database>>
for this, won't you need to make a server side request and then check for its existence? I dont think this is in the scope of struts validator.

i would suggest that you make an ajax request to check for its existence, so that user can continue to fill other fields
0
 

Assisted Solution

by:moj123456
moj123456 earned 800 total points
ID: 34109935
Depends what kind of 'validation' you want.

If you want to do client-side validation, you have no choice but Ajax.

If you want to do server-side validation, then the user will have to submit the form and consequently you can use code to validate it.

You cannot do client-side validation with simple javascript due to the fact that the userlist is lying in the DB (which the client, being a web browser on another computer, does not have access to).
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question