[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

How do I call this js?

Asked by sammySeltzer in JavaScript

Greetings all,

A former employee put this js file together but I could not find out it is being called.

Can you please help?

Here is a snippet of the code and how I am trying to call it.


function validateField( fld, flags, name )
{
    // alert("validate(" + fld.value + "," + flags + "," + name + ")");
    var ftype = flags.charAt(0).toUpperCase();
    var numat = 1;
    var zeroOk = false;
    var minSize = 0;
    var maxSize = 255;
    if ( flags.charAt(1).toUpperCase() == "Z" )
    {
        zeroOK = true;
        numat = 2;
    }
    if ( flags.length > numat )
    {
        var nums = flags.substring(numat).split(/\_/);
        minSize = parseInt(nums[0]);
        if ( nums.length > 1 ) maxSize = parseInt(nums[1]);
    }
    // okay, ready for anthing...he says
    var fval = null;
    switch ( ftype )
    {
        case "C":
            fval = validateCurrency(fld);
            if ( fval == null ) return name + " is not a valid currency value";
            if ( fval == 0 && ! zeroOk ) return name + " can not be zero";
            if ( fval < minSize || fval > maxSize)
                return name + " must be between " + minSize + " and " + maxSize;
            return "";
        case "D":
            fval = validateDate(fld);
            if ( fval == null ) return name + " is not a valid date of the form mm/dd/yyyy";
            return "";
        case "E":
            fval = validateEmail(fld);
            if ( fval == null ) return name + " is not a valid email address";
            return "";
        case "F":
            fval = validateFloat(fld);
            if ( fval == null ) return name + " is not a valid decimal value";
            if ( fval == 0 && ! zeroOk ) return name + " can not be zero";
            if ( fval < minSize || fval > maxSize)
                return name + " must be between " + minSize + " and " + maxSize;
            return "";
        case "I": case "N":
            fval = validateInteger(fld);
            if ( fval == null ) return name + " is not a valid numeric value";
            if ( fval == 0 && ! zeroOk ) return name + " can not be zero";
            if ( fval < minSize || fval > maxSize)
                return name + " must be between " + minSize + " and " + maxSize;
            if ( ftype == "I" && fval < 0 ) return name + " cannot be negative";
            return "";
        case "P":
            fval = validatePhone(fld);
            if ( fval == null ) return name + " is not a valid 10 or 11 digit phone number";
            return "";
        case "S":
            fval = fld.value.replace(/^\s+/,"").replace(/\s+$/,""); // trim()
            fld.value = fval;
            if ( fval < minSize || fval > maxSize)
                return name + " must have between " + minSize + " and " + maxSize + " characters";
            return "";
        case "T":
            fval = validateTime(fld);
            if ( fval == null ) return name + " is not a valid time of the form hh:mm:ss";
            return "";
        case "R":
            var rre = new RegExp(flags.substring(1));
            if ( ! rre.test(val) ) return name + " does not match required pattern";
            return "";
        case "X": case "*":
            var cbs = fld.form.elements[ fld.name ];
            if ( cbs.length == null )
            {
                // single checkbox...so it can only be optional or not
                if ( ! cbs.checked && minSize > 0 ) return "You must check in checkbox " + name;
                return "";
            }
            if ( cbs[0] != fld ) return "#"; // special flag: not first checkbox of set
            var cnt = 0;
            for ( c = 0; c < cbs.length; ++c )
            {
                if ( cbs[c].checked ) ++cnt;
            }
            if ( cnt < minSize || cnt > maxSize )
            {
                return "You must check " + minSize + " to " + maxSize + " " + name + " checkboxes";
            }
            return "";
        default:
            return "\n*** ERROR: Invalid type flag, " + ftype + "\n";
    }
}

function validateDate(fld)
{
    var dateRE = /^(0?[1-9|1[012])\-(0?[1-9]|[12]\d|3[01])\-(19|20)\d\d$/
    //    var dateRE = /^\d\d?\-\d\d?\-(19|20)\d\d$/

    var val = fld.value.replace(/[\s\/\.]/g,"-");
    val = val.replace(/[^\d\-]/g,"");
    val = val.replace(/\-+/g,"-");
    if ( ! dateRE.test(val) ) return null;
    var pcs = val.split(/\-/);
    if ( pcs.length != 3 ) return null;
    var mn = parseInt(pcs[0])-1;
    var dt = new Date( parseInt(pcs[2]), mn, parseInt(pcs[1]) );
    if ( mn != dt.getMonth() ) return null;
    fld.value = val;
    return val;
}


THen I would like to use the above to ensure date field is not blank.

<input type=text name=sentDate value="">

How do I use the js with the above input box?

Thanks a million
[+][-]07/06/09 07:53 AM, ID: 24785760Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: JavaScript
Sign Up Now!
Solution Provided By: HonorGod
Participating Experts: 2
Solution Grade: A
 
[+][-]07/05/09 06:23 PM, ID: 24781942Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/05/09 06:31 PM, ID: 24781960Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/05/09 06:39 PM, ID: 24782000Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/05/09 06:53 PM, ID: 24782068Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/05/09 06:54 PM, ID: 24782077Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/05/09 06:56 PM, ID: 24782082Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/05/09 07:06 PM, ID: 24782134Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/06/09 03:18 AM, ID: 24783795Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/06/09 08:47 AM, ID: 24786372Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/06/09 10:14 AM, ID: 24787222Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/06/09 04:17 PM, ID: 24790106Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20090701_SELECT_ZONES