Email validation but not required

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

It must be easy!!! Please somebody can help me?

Thanks!,
Oskar

Email validation but not required

I 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

any idea?

Email validation but not required

Hi,

You could try replacing line 161-163 in the forms.xml to:

<s:when b:test="@b:validation='email' and not(@b:required='false' and normalize-space(@value)='')">
  <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

thanks
it works.

How can I do this in BB 4.1.2

How 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

Hi 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".

<script type="text/backbase+xml"
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