Expand my Community achievements bar.

SOLVED

Writing text in upper case.

Avatar

Level 2

Форма разработана в LiveCycle 9. Поле используется для ввода текста в нижнем регистре. Необходимо, чтобы во время ввода текста ("изменить" событие) в первых букв слов появляются в верхнем регистре. Написано следующий код:

            < событие деятельность = " изменение " имя = " event__change ">

               < сценарий CONTENTTYPE = " применение / х-JavaScript ">

если (xfa.event.newText.length> xfa.event.prevText.length && xfa.event.change.length == 1)

{

xfa.event.change = xfa.form.topmostSubform.variables.Validation.VerchReg (xfa.event.change);

}

еще

{

xfa.event.change = "";

}

</ сценарий >

            </ событие >

  < переменные >

         < сценарий CONTENTTYPE = " применение / х-JavaScript " название = " Проверка ">

вар первый = верно;

функционировать VerchReg (newsymbol)

{

вар повторно = / [А-Яа-я-""] / ;/ / Вводятся только кириллица - и пробел

если (re.test (newsymbol))

{

если (newsymbol == "")

{

  Первый = верно;

  вернуться newsymbol;

}

если (первый)

{

Первый = ложь;

вернуться newsymbol.toUpperCase ();

}

еще

{

вернуться newsymbol;

}

}

еще

{

вернуться "";

}

}

}

</ сценарий >

         <? TemplateDesigner расширить 1?> </ переменные >

Проблема: когда форма открывается в первый раз при вводе текста в нижнем регистре (например: Воронеж, Вологда, Россия, Москва, все работает хорошо и получить результат Вологодской Воронежской Москве), однако, если стереть все печатные, и начать еще раз для входа в нижнем регистре Воронеж, Вологда, Россия Москва, я получаю результат vologda Воронеж Москва, то есть, первое слово в нижнем регистре. Если вы удалите все печатные и, прежде чем вводить новые слова в поле поставить пробел, а затем удалить его и начать немедленно повторно ввести текст все работает как надо, то есть результат Вологда Воронеж Москва. Может кто подскажет, что проблема.


1 Accepted Solution

Avatar

Correct answer by
Level 2

Form is developed in LiveCycle 9. Field is used to input text in lower case. It is necessary that during text input ("change" event)in the first letters of the words appear in uppercase. Written the following code:

            <event activity="change" name="event__change">

               <script contentType="application/x-javascript">

if (xfa.event.newText.length &gt; xfa.event.prevText.length &amp;&amp; xfa.event.change.length ==1)

{

  1. xfa.event.change = xfa.form.topmostSubform.variables.Validation.VerchReg(xfa.event.change);

}

else

{

  1. xfa.event.change = "";

}

</script>

            </event>

  <variables>

         <script contentType="application/x-javascript" name="Validation">

var first=true;

function VerchReg(newsymbol)

{

var re = /[А-Яа-я-" "]/;//Вводятся только кириллица - и пробел

if (re.test(newsymbol))

{

if (newsymbol==" ")

{

  first=true;

  return newsymbol;

}

if (first)

{

first=false;

return newsymbol.toUpperCase();

}

else

{

return newsymbol;

}

}

else

{

return "";

}

}

}

</script>

         <?templateDesigner expand 1?></variables>

Problem: when the form is first opened when entering text in lower case (for example: Voronezh, Vologda, Russia, Moscow, all works well and get the result of the Vologda Voronezh Moscow), however, if the erase all printed, and begin again to enter in lower case Voronezh, Vologda, Russia Moscow, I get the result of the vologda Voronezh Moscow, that is, the first word appear in lowercase. If you delete all printed and before you enter new words in the box to put a space, then delete it and start immediately re-enter text all works as it should, that is the result Voronezh, Vologda and Moscow. Can someone tell me what the problem is.

View solution in original post

2 Replies

Avatar

Level 10

I am sorry i dont understand anything above, but this might help you,

for uppercase you can always use the method .toUpperCase()

e.g.

this.rawValue = this.rawValue.toUpperCase();

Avatar

Correct answer by
Level 2

Form is developed in LiveCycle 9. Field is used to input text in lower case. It is necessary that during text input ("change" event)in the first letters of the words appear in uppercase. Written the following code:

            <event activity="change" name="event__change">

               <script contentType="application/x-javascript">

if (xfa.event.newText.length &gt; xfa.event.prevText.length &amp;&amp; xfa.event.change.length ==1)

{

  1. xfa.event.change = xfa.form.topmostSubform.variables.Validation.VerchReg(xfa.event.change);

}

else

{

  1. xfa.event.change = "";

}

</script>

            </event>

  <variables>

         <script contentType="application/x-javascript" name="Validation">

var first=true;

function VerchReg(newsymbol)

{

var re = /[А-Яа-я-" "]/;//Вводятся только кириллица - и пробел

if (re.test(newsymbol))

{

if (newsymbol==" ")

{

  first=true;

  return newsymbol;

}

if (first)

{

first=false;

return newsymbol.toUpperCase();

}

else

{

return newsymbol;

}

}

else

{

return "";

}

}

}

</script>

         <?templateDesigner expand 1?></variables>

Problem: when the form is first opened when entering text in lower case (for example: Voronezh, Vologda, Russia, Moscow, all works well and get the result of the Vologda Voronezh Moscow), however, if the erase all printed, and begin again to enter in lower case Voronezh, Vologda, Russia Moscow, I get the result of the vologda Voronezh Moscow, that is, the first word appear in lowercase. If you delete all printed and before you enter new words in the box to put a space, then delete it and start immediately re-enter text all works as it should, that is the result Voronezh, Vologda and Moscow. Can someone tell me what the problem is.