• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

regular expression not to start with hypen

New Here ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

I need a adobe acrobat javascript for text not be start with hyphen.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

311

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 11, 2017 Jul 11, 2017

So this is a custom Keystroke script? If so, try this:

var RE_Alpha = /^[A-Za-z_ -]*$/;

var RE_Hyphen = /^-/;

event.rc = RE_Alpha.test(event.change) && !RE_Hyphen.test(AFMergeChange(event));

Votes

Translate

Translate
Community Expert ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

As a validation script? You can use this:

if (/^-/.test(event.value)) {

    app.alert("The value must not begin with a hyphen.");

    event.rc = false;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

Thanks for your reply,this is my code below.but this working with  start on hyphen. but i don't want to start with hyphen. please help me sir.

if(event.fieldFull == true){

    alertDialog(errorMsgs.msg007);

}

if (event.willCommit == false) {

    var RE_Alpha = /^[A-Za-z_ -]*$/;

    event.rc = RE_Alpha.test(event.change);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

So this is a custom Keystroke script? If so, try this:

var RE_Alpha = /^[A-Za-z_ -]*$/;

var RE_Hyphen = /^-/;

event.rc = RE_Alpha.test(event.change) && !RE_Hyphen.test(AFMergeChange(event));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

LATEST

thanks a lot sir.this is working

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines