Purchase Solution

Javascript Problem

Not what you're looking for?

Ask Custom Question

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.

The problem is as follows:

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.

Could anyone please help give me aclue as to why this is?

Thanks

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
}
}.

Purchase this Solution

Solution Summary

The solution assists with solving the given Javascript problem.

Solution Preview

function checkDate(textObj)
{
datetestCheck = 0;
holdString = textObj.value
secondHold = parseInt(holdString,10)
if (secondHold != NaN || holdString.length != 8)
{
datetestCheck = datetestCheck ...

Purchase this Solution


Free BrainMass Quizzes
C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

C# variables and classes

This quiz contains questions about C# classes and variables.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.