- From: Raghu Krishnamurthy <raghu.krishnamurthy@oracle.com>
- Date: Thu, 27 Nov 2003 15:43:00 +0530
- To: www-forms@w3.org
- Message-ID: <3FC5CE2C.AE9EBC28@oracle.com>
All
I have a textbox that needs to be mandatory and also that the number of
characters in it should not be more than 3 characters.
I have these constraints defined thus.
<xforms:bind nodeset="/my:Eform/my:Summary" required="true()"
id="bind_1" constraint="string-length( normalize-space(.) ) < 3"/>
I have my UI as follows
<xforms:textarea id="input_0" ref="/my:Eform/my:Summary">
<xforms:label id="label_1">Summary</xforms:label>
<xforms:message ev:event="xforms-invalid">
'Summary' is a mandatory field
</xforms:message>
<xforms:message ev:event="xforms-invalid">
Cannot contain more than 3 characters
</xforms:message>
</xforms:textarea>
You notice that I want to display 2 different alerts at diff times.
That is if nothing is entered in the textbox,I want the alert to just
say("'Summary' is a mandatory field");
If something is entered and the number of charactes are more than 3
then,I want just Cannot contain more than 3 characters
to be displayed.
However with the above code both the messages will get displayed if
either of them is not satisfied.
I have not been able to do these kind of validations as easily I was
doing with javascript
where I would have complete control.
I am sure it will be possible though with xforms events also.Any help
would be great.
Thanks and Best Regards
Raghu
Raghu Krishnamurthy wrote:
> All
>
> I have an xforms document that has a few text fields.
> The different validations are that textbox1 should be mandatory,
> textbox2 should be only a date and textbox3 should contain less than
> 10 characters.
>
> I have the constraints defined thus
> <xforms:bind nodeset="/my:Eform/my:Summary" required="true()"
> id="bind_1"/>
> <xforms:bind nodeset="/my:Eform/my:Referral.Rejected.-.Reasons"
> id="bind_8" type="xsd:date" format="YYYY-MM-DD"/>
> <xforms:bind nodeset="/my:Eform/my:Desired.Outcome.of.the.Service"
> id="bind_4" constraint="string-length( normalize-space(.) ) <
> 10"/>
>
> The ui would be as follows
> <xforms:textarea id="input_0" rows="1" cols="80"
> ref="/my:Eform/my:Summary">
> <xforms:label id="label_1"><span
> style="color:#ff0000;font-weight:700">Summary</span></xforms:label>
> <xforms:message
> ev:event="xforms-invalid">
> This is a mandatory field
> </xforms:message>
> </xforms:textarea>
>
> Now the problem I have is that as you can see in the
> <xforms:message ev:event="xforms-invalid">
> This is a mandatory field
> </xforms:message>
>
> the event gets fired whenever the instance is invalid.
> This is fine,but when the form is displayed for the first time to the
> user,the instance will be an empty instance as the fields would not
> contain any data.
> like <Summary></Summary>
> So when the form is first time displayed to the user,these alerts come
> up while rendering the form as the instance data would not comply with
> the constraints set.
> Ideally I want the form to display without any alerts and when the
> user enters data and then tabs out to other fields or hits the submit
> button,I want the alert messages to be displayed and not while the
> form is getting rendered.
> Would anybody please let me know how to do that?
>
> Thanks and Best Regards
> Raghu
Received on Thursday, 27 November 2003 05:37:11 UTC