I think there is a better option than just using regex for email validation, that is use apache common validator to do the same thing in an easy manner. like
EmailValidator.getInstance().isValid(emailAddress); Howard Lewis Ship wrote: > > I agree: > - onblur vs. onform submit > - option to validate via server-round trip (especially for onblur) > > On 5/17/07, kranga <[EMAIL PROTECTED]> wrote: >> >> We just introduced client side validation for Tapestry fields using an >> ajax >> call back to the server side (with Tapestry 3). So you only write Java >> code >> for the validation and the same code gets called from the client side. >> All >> parameters for controlling your validation are automatically sent back as >> part of the ajax call and you can define when the check is triggered >> (e.g. >> onBlur) and which one of the "error marker" components tied to the input >> field will show the errors. Makes the code very clean and the front-end >> experience is slick (e.g. registration page has the same validator to >> check >> if username is taken and this is fired from the client and from the >> server!). I'd suggest T5 move to such a design. >> >> ----- Original Message ----- >> From: "Bill Holloway" <[EMAIL PROTECTED]> >> To: "Tapestry users" <users@tapestry.apache.org> >> Sent: Wednesday, May 16, 2007 2:27 PM >> Subject: Re: T5: New Validators and server side validation >> >> >> > That's got it, Ben. Thanks. Wish I knew more about javascript >> > prototyping. Too much technology to stay familiar with. >> > >> > Bill >> > >> > On 5/16/07, Ben Sommerville <[EMAIL PROTECTED]> wrote: >> >> Bill, >> >> >> >> This >> >> > pageRenderSupport.addScript( >> >> > "Tapestry.Field.email('%s', %s);", >> >> > field.getClientId(), >> >> > quote(buildMessage(formatter, field))); >> >> >> >> does not construct a function validating emails. What it is doing is >> >> inserting >> >> a function call to register a particular field for validation. >> >> >> >> On the page sent to the client you would get something like >> >> >> >> <script language="javascript" type="text/javascript"> >> >> <!-- >> >> Tapestry.registerForm('MyFormId'); >> >> Tapestry.Field.email('MyFieldId','My message ')l >> >> --> >> >> </script> >> >> >> >> That is the source of your error message, the Tapestry.Field.email >> >> function >> >> does not exist but you are trying to call it. >> >> >> >> What you need to do is define the email validation function yourself >> in >> a >> >> javascript file. I would add it to a different namespace so that it >> is >> >> clear >> >> it is not a standard Tapestry function. >> >> >> >> e.g. in myproject-valdation.js >> >> >> >> var MyProject = {}; >> >> >> >> MyProject.Field = { >> >> >> >> email: function(field, message) { >> >> Tapestry.addValidator(field, false, function(value, event) { >> >> if( XXXXX ) { >> >> event.recordError(message) >> >> } >> >> }); >> >> } >> >> } >> >> >> >> where XXXX is the javascript to test if "value" is a valid email >> address. >> >> >> >> Add a script include to your border/page (to load your validation >> >> function) >> >> <script language="javascript" type="text/javascript" >> >> src="js/myproject-validation.js"></script> >> >> >> >> and change the render method to use MyProject.Field.email and you are >> >> good >> >> to go >> >> >> >> cheers. >> >> -- >> >> Ben Sommerville >> >> >> >> >> >> >> >> > -----Original Message----- >> >> > From: Bill Holloway [mailto:[EMAIL PROTECTED] >> >> > Sent: Wednesday, 16 May 2007 4:33 PM >> >> > To: Tapestry users >> >> > Subject: Re: T5: New Validators and server side validation >> >> > >> >> > In implementing an e-mail validator myself, one thing I notice in >> all >> >> > this is a Javascript error that reads >> >> > >> >> > Error: Tapestry.Field.email is not a function... >> >> > >> >> > I did some digging and found in org/apache/tapestry/tapestry.js the >> >> > building up of the Tapestry object has in it a section involving >> >> > "Collection of field based functions related to validation." In >> that >> >> > part of the object prototyping (I guess), each of the built-in >> >> > validation types (required, minlength, maxlength, min, and max) has >> a >> >> > function assigned that, essentially, duplicates the functionality of >> >> > the Java-based validators. All that prototyping must be for the >> >> > client-side functionality. >> >> > >> >> > So I'm wondering why my AppModule-provided EmailValidator class' >> >> > render() method isn't contributing the script. Its code is >> >> > >> >> > pageRenderSupport.addScript( >> >> > "Tapestry.Field.email('%s', %s);", >> >> > field.getClientId(), >> >> > quote(buildMessage(formatter, field))); >> >> > >> >> > Since I implementing something for render(), I would think that at >> >> > least some kind of function for Tapestry.Field.email would show up >> >> > (even if it has the wrong number of fields, etc), knocking out the >> >> > "...is not a function" error. >> >> > >> >> > Bill >> >> > >> >> >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> > >> > >> > -- >> > "The future is here. It's just not evenly distributed yet." >> > >> > -- Traditional >> > >> > --------------------------------------------------------------------- >> > To unsubscribe, e-mail: [EMAIL PROTECTED] >> > For additional commands, e-mail: [EMAIL PROTECTED] >> > >> > >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > -- > Howard M. Lewis Ship > TWD Consulting, Inc. > Independent J2EE / Open-Source Java Consultant > Creator and PMC Chair, Apache Tapestry > Creator, Apache HiveMind > > Professional Tapestry training, mentoring, support > and project work. http://howardlewisship.com > > -- View this message in context: http://www.nabble.com/T5%3A-New-Validators-and-server-side-validation-tp10616222p15822320.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]