textarea problem when checking for number of words entered

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

textarea problem when checking for number of words entered

Alexander Žaťko
Using OPS nightly build from 3-4 days ago with XForms NG.

I have a textarea in my form and I want to restrict users from being able to paste more that certain number of words. I have adapted the registration form from the OPS examples for my purposes and I have it working fine when user types the content in, but when user copies text from an outside document and pastes large amount of text in, the form real-time validation slows down to such a degree as to make impression that the browser froze. On Firefox I am getting the "Script unresponsive" message and IE just looks like it is frozen. Below are the relevant portions of my form. Maybe you guys can advise what could I do to avoid this?

Relevant model sections:

<presentation-abstract 
sgrt:started-typing="false" 
sgrt:valid="" 
sgrt:show-valid="" 
sgrt:show-invalid="" 
sgrt:is-textarea="true" 
sgrt:label="Presentation Abstract" 
sgrt:error="Please enter less than 500 words" 
sgrt:hint=""/>


<xforms:bind nodeset="presentation-abstract" required="true()">
<xforms:bind nodeset="@sgrt:valid" calculate="(count(tokenize(..,' ')) &gt; 0) and (count(tokenize(..,' ')) &lt; 500)"/>
<xforms:bind nodeset="@sgrt:show-valid" relevant="../@sgrt:started-typing = 'true' and ../@sgrt:valid = 'true'"/>
<xforms:bind nodeset="@sgrt:show-invalid" relevant="../@sgrt:started-typing = 'true' and ../@sgrt:valid = 'false'"/>
</xforms:bind>

The body of the XHTML page contains this snippet:

<xforms:setvalue ref="presentation-abstract/@sgrt:started-typing" ev:event="xforms-value-changed">true</xforms:setvalue>
<xforms:output ref="presentation-abstract/@sgrt:error"/>
<xhtml:br>
  <xforms:textarea ref="presentation-abstract" incremental="true" class="input-textarea" appearance="xxforms:autosize">
    <xforms:help ref="@sgrt:hint"/>
  </xforms:textarea>
</xhtml:br>
<xforms:group ref="presentation-abstract/@sgrt:show-valid" class="valid"/>
<xforms:group ref="presentation-abstract/@sgrt:show-invalid" class="invalid">
  <xforms:output ref="../@sgrt:error"/>
</xforms:group>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: textarea problem when checking for number of words entered

Alexander Žaťko
Removing:
                      appearance="xxforms:autosize"

...from the xforms:textarea solved the problem.

On Aug 18, 2006, at 11:43 AM, Alexander Zatko wrote:

Using OPS nightly build from 3-4 days ago with XForms NG.

I have a textarea in my form and I want to restrict users from being able to paste more that certain number of words. I have adapted the registration form from the OPS examples for my purposes and I have it working fine when user types the content in, but when user copies text from an outside document and pastes large amount of text in, the form real-time validation slows down to such a degree as to make impression that the browser froze. On Firefox I am getting the "Script unresponsive" message and IE just looks like it is frozen. Below are the relevant portions of my form. Maybe you guys can advise what could I do to avoid this?

Relevant model sections:

<presentation-abstract 
sgrt:started-typing="false" 
sgrt:valid="" 
sgrt:show-valid="" 
sgrt:show-invalid="" 
sgrt:is-textarea="true" 
sgrt:label="Presentation Abstract" 
sgrt:error="Please enter less than 500 words" 
sgrt:hint=""/>


<xforms:bind nodeset="presentation-abstract" required="true()">
<xforms:bind nodeset="@sgrt:valid" calculate="(count(tokenize(..,' ')) &gt; 0) and (count(tokenize(..,' ')) &lt; 500)"/>
<xforms:bind nodeset="@sgrt:show-valid" relevant="../@sgrt:started-typing = 'true' and ../@sgrt:valid = 'true'"/>
<xforms:bind nodeset="@sgrt:show-invalid" relevant="../@sgrt:started-typing = 'true' and ../@sgrt:valid = 'false'"/>
</xforms:bind>

The body of the XHTML page contains this snippet:

<xforms:setvalue ref="presentation-abstract/@sgrt:started-typing" ev:event="xforms-value-changed">true</xforms:setvalue>
<xforms:output ref="presentation-abstract/@sgrt:error"/>
<xhtml:br>
  <xforms:textarea ref="presentation-abstract" incremental="true" class="input-textarea" appearance="xxforms:autosize">
    <xforms:help ref="@sgrt:hint"/>
  </xforms:textarea>
</xhtml:br>
<xforms:group ref="presentation-abstract/@sgrt:show-valid" class="valid"/>
<xforms:group ref="presentation-abstract/@sgrt:show-invalid" class="invalid">
  <xforms:output ref="../@sgrt:error"/>
</xforms:group>




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws