Avatar

Level 4

I am working on timesheet form

I have Start and End time fields:

 

Date/Time field

Pattern is set this way

Display: time{KK:MM}

Edit : time{KK:MM}|time{KKMM}|time{KK MM}|time{KK-MM}|time{KK.MM.SS}|time{KK.MM}|time{KK,MM}

Data and Validate tabe are empty:

This is the code on Exit event:

if

(this.formattedValue === this.rawValue)

{

xfa.host.messageBox("Please enter correct data format");

xfa.host.setFocus(

this);

this.rawValue

= "";

}

This is the code on Change event:

var

maxLength = 4;

if

(xfa.event.newText.length > maxLength )xfa.event.change = "";

 

 

On validate event I have a code that calls function to make sure no letters are allowed

On Validate:

docLevel.validateField(this.name

,docLevel.onlyNum,docLevel.onlyNumMsg);

 

Function is :

var

onlyNum = /^\d*$/;

var

onlyNumMsg = " Please enter only numeric values.";

function

validateField (getField, getRegex, getAlertMsg)

{

var

fieldFocus = xfa.resolveNode(getField);

var

regex = new RegExp();

regex.compile(getRegex);

var

runRegex = regex.test(fieldFocus.rawValue);

if

(fieldFocus.rawValue != null && runRegex == false)

{

app.alert(getAlertMsg

, 1, 0, "Numeric fields error");

fieldFocus.rawValue

= null;

xfa.host.setFocus(getField);

}

}

 

I have few questions:

1. why it does not allow me to enter e.g 23:22

2. why when I enter 2345 does not recognize it as a numeric value and give me an error message "

" Please enter only numeric values.";

What am I missing to be able to enter value like 1111 to have 11:11 or 23:11 correctly formated.Btw, how do I attache sample form I have to show the issue?