Hello,
I have this:
But it is always required. What I want is that if the user inputs something, validate it as an email, but if not, leave the form be submitted without problems.
Can't this be done?
Thank you very much for your support,
Oskar
Hello,
I have this:
But it is always required. What I want is that if the user inputs something, validate it as an email, but if not, leave the form be submitted without problems.
Can't this be done?
Thank you very much for your support,
Oskar
Email validation but not required
8 May, 2007 - 10:55 — AnonymousIt must be easy!!! Please somebody can help me?
Thanks!,
Oskar
Email validation but not required
8 May, 2007 - 11:23 — AnonymousI have the same problem and I did the change below in forms.xml but it doesn't affect.
I really confused, any idea?
Email validation but not required
16 May, 2007 - 09:00 — Anonymousany idea?
Email validation but not required
16 May, 2007 - 16:45 — AnonymousHi,
You could try replacing line 161-163 in the forms.xml to:
<s:choose>
<s:when b:test="not(regexp(@value, '^.+@(.+\.)+[a-zA-Z]{2,}$'))">
<s:setatt b:valid="false" b:infomsg="The email address should be in the form user@domain.com" />
</s:when>
<s:otherwise>
<s:setatt b:valid="true" />
</s:otherwise>
</s:choose>
</s:when>
I think that should work.
Happy coding.
Email validation but not required
29 May, 2007 - 11:14 — Anonymousthanks
it works.
How can I do this in BB 4.1.2
19 March, 2008 - 16:36 — BramHow can I do this in BB 4.1.2?
Placing the suggested code in forms.xml does not fix it. To me it seems like a flaw in the framework. I didn't specify the field as required, so why can't it be empty?
How can I do this in BB 4.1.2
19 March, 2008 - 19:16 — yudiHi Bram,
You can also do this in BB 4.1.2. You create your own schema for email and apply the schema in email input by using bf:dataType="yourOwnSchema".
xmlns="http://www.w3.org/1999/xhtml"
....
xmlns:bf="http://www.backbase.com/2007/forms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:example="http://example.org/ns/my-datatypes">
<!-- The custom datatypes -->
<xs:schema targetNamespace="http://example.org/ns/my-datatypes">
<xs:simpleType name="emailValidation">
<xs:restriction base="xs:token">
<xs:pattern value="^.+@(.+\.)+[a-zA-Z]{2,}$"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
<input ..bf:dataType="example:emailValidation" ../> // your email input form
Cheers,
Yudi