How to check the validation of string


Assignment:

EXAMPLE:

I use the function so when I fill in the form it checks that the date is an integer or the date is of length 8 (format ddmmyyyy.) If it is neither 8 digits in length nor equal to the parsed value then the form cannot be validated and an error message is brought up. This function is called on form validation.

Q: When I enter a date not starting with 0 this function works as required however if the date starts with 0 it will not validate as secondHold and holdString no longer equal. i.e.

textObj.value = 21081985 Then the validation works correctly and holdString == secondHold.

textObj.value = 01081985 Then the validation does NOT work and holdString != secondHold.

The function is as follows:
JC

function checkDate(textObj)
{
datetestCheck = 0;
holdString = textObj.value
secondHold = parseInt(holdString)
if (secondHold != holdString || holdString.length != 8)
{
datetestCheck = datetestCheck + 1;
return true
}
else
{
return false
}
}

Solution Preview :

Prepared by a verified Expert
JAVA Programming: How to check the validation of string
Reference No:- TGS01938311

Now Priced at $20 (50% Discount)

Recommended (99%)

Rated (4.3/5)