regular expression not to start with hypen

New Here ,
Jul 11, 2017

Copy link to clipboard

Copied

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

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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));

TOPICS
Acrobat SDK and JavaScript, Windows

Views

138

Likes

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

regular expression not to start with hypen

New Here ,
Jul 11, 2017

Copy link to clipboard

Copied

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

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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));

TOPICS
Acrobat SDK and JavaScript, Windows

Views

139

Likes

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
Jul 11, 2017 0
Most Valuable Participant ,
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;

}

Likes

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
Reply
Loading...
Jul 11, 2017 0
New Here ,
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);

}

Likes

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
Reply
Loading...
Jul 11, 2017 0
Most Valuable Participant ,
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));

Likes

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
Reply
Loading...
Jul 11, 2017 0
New Here ,
Jul 11, 2017

Copy link to clipboard

Copied

thanks a lot sir.this is working

Likes

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
Reply
Loading...
Jul 11, 2017 0