validating an entry in a repeated region.

I have a script that will validate an entry in a repeated region to make sure its a date in format:  mm/dd/yyyy

The element goes like:

<input name="<%= (iCount & ".Qty") %>" type="text" class="bodytext" id="<%= (iCount & ".Qty") %>" value="<%= DoDateTime((StepsHistory.Fields.Item("LastModified").Value), 2, 9225) %>" size="10" maxlength="10" onBlur="validateDate(this);">

Open in new window


This is the part that runs the validation:    onBlur="validateDate(this);"

All works great, the script is below.

I need to modify the script and have it on a separate one to validate an entry is a positive integer (including zero). so that I can add :

onBlur="validateint(this);"

And have that element validated as:

<<input name="<%= (iCount & ".Qty1") %>" type="text" class="bodytext" id="<%= (iCount & ".Qty1") %>" value="<%=(StepsHistory.Fields.Item("responsible").Value)%>" size="3" maxlength="3" onBlur="validateint(this);">

Open in new window


This is the script to validate the date (mm/dd/yyyy), I would greatly appreciate any help to tweak it so that I can save it as a new script to validate the data being entered is a postivie integer:

<script type="text/javascript">
<!--
function validateDate(fld) {
    var RegExPattern = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;
    var errorMessage = 'Please enter the date in the required format (mm/dd/yyyy)';
    if (fld.value != "" && !fld.value.match(RegExPattern)) {
        alert(errorMessage);
        fld.focus();
    } 
	
}
//-->

</script>

Open in new window

LVL 1
AleksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

F IgorDeveloperCommented:
Simple if the integer number it's only with numbers (no thousand separators)

function validateDate(fld) {
    var RegExPattern = /^[0-9]+$/;
    var errorMessage = 'Please enter a valid integer value';
    if (fld.value != "" && !fld.value.match(RegExPattern)) {
        alert(errorMessage);
        fld.focus();
    } 
}

Open in new window



For integers with thousand separators (. in this case)

function validateDate(fld) {
    var RegExPattern = /^(?!0+\.00)(?=.{1,9}(\.|$))\d{1,3}(,\d{3})*$/;
    var errorMessage = 'Please enter a valid integer value';
    if (fld.value != "" && !fld.value.match(RegExPattern)) {
        alert(errorMessage);
        fld.focus();
    } 
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AleksAuthor Commented:
Perfect ! thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.