SitePoint Sponsor

User Tag List

Page 9 of 13 FirstFirst ... 5678910111213 LastLast
Results 201 to 225 of 310
  1. #201
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Here's the problem.

    Code:
    $(row).rules('add', rule);
    You can only add a validation rule to form fields, not to other HTML elements that are on the page.

    Because you have used $('[name^="locationFrom"]', row) a couple of times in the function, and will need to use it again to add that rule for that form field, now is a good time to assign it to a variable and use that variable throughout the function.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  2. #202
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Can you visit this site now http://183.78.169.54/v3/addRoute.php. There is no error but when will it validate that the locationFrom and locationTo column are both same.I try to submit but there is not validation on it.Below is my latest codes.

    function matchingFromAndTo(row)
    {
    //alert("ID : "+$('[name^="locationFrom"]', row).attr('name'));
    var rowName="";
    rowName = $('[name^="locationFrom"]', row);
    var rule = {};
    rule[$('[name^="locationFrom"]', row).attr('name')] =
    {
    required: function(element) {
    var row="",locationToValue="";
    row = $(element).parents('tr');
    locationToValue=$('[name^="locationTo"]', row).attr('value');
    return $(element).val()==$(element).parents('tr').find("td").eq(4).val();

    }
    }
    $(rowName).rules('add', rule);

    }

  3. #203
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    There is no error but when will it validate that the locationFrom and locationTo column are both same
    Currently it doesn't because you haven't added the rule to the select field. Currently you are adding the rule to the entire row, which is just ignored by the validator. The rule needs to be added to a form field, such as the select field, for it to be used during the validation process.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #204
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Where must I put this additional codes and what must the codes be? Isnt this adding it at the column of the particular row $(rowName).rules('add', rule);?

  5. #205
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Where must I put this additional codes and what must the codes be? Isnt this adding it at the column of the particular row $(rowName).rules('add', rule);?
    Not to the column, no. It's adding it to the row. You can tell that because of the rowName variable.

    Instead of adding the rule to the row, you need to add the rule to the drop-down select field itself.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #206
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I need your help on how to do this I am not too sure on how to proceed with the column level.

  7. #207
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    I need your help on how to do this I am not too sure on how to proceed with the column level.
    Oh hang on, my last post might be wrong because rowName is a misleading variable name. That's the select element itself.

    Hang on, major earthquake happening here, feels like a 5.5 at least. Checking on family...
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #208
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Is ok please check your family first then only get back to me ok no worries. Later only you correct this. Thank you.

  9. #209
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Is ok please check your family first then only get back to me ok no worries. Later only you correct this. Thank you.
    You may be interested in taking a look at the quake drum readings at GeoNet -Seismograph Drums - McQueens Valley (MQZ), Canterbury, New Zealand
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #210
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    How are you and your family? All fine? You are still in christchurch is it?

  11. #211
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    How are you and your family? All fine? You are still in christchurch is it?
    They're shaken but okay. They live on the hill that's right over one of the main fault lines. I'm just a few kilometres away from the hills too. This large quake came from a completely new location.

    Site's very busy right now, but pretty pictures of it are at http://quake.crowe.co.nz/QuakeMap/Single/

    You can also see details from GeoNet - Recent New Zealand Earthquakes
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  12. #212
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Your family here means your kids,wife and parents is it? What do you work as? Are you working for site point? So do update me your situation hope all is cool off by now.

  13. #213
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Your family here means your kids,wife and parents is it? What do you work as? Are you working for site point? So do update me your situation hope all is cool off by now.
    I finalized a divorce earlier this year (I chose to separate) and fortunately there are no kids in the mix. The parents were relieved about the separation too.

    Currently I'm freelancing (poor, looking for work) which is why I'm volunteering here to keep some of my skills nice and sharp.

    The tea-cup is still rattling with aftershocks. That was a nasty quake we had before, and the tea-cup is still rattling from the aftershocks still coming through.

    The quake drum at GeoNet - Seismograph Drums - McQueens Valley (MQZ), Canterbury, New Zealand updates every 10 minutes, so you can keep up to date with what's happening here. The red bits on it are where the needle goes off the scale. They're the bad bits. There are a lot of them.

    In fact, if you go to Seismograph Drums - New Zealand National Seismograph Network page, you'll see it was felt across virtually the whole country.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  14. #214
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    How are you settle down? Better now? I can still see the red dots. So where are you now back home is it? Take care.

  15. #215
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Hope all is ok with u there and things are back to normal. So how to tag the validation to the select statement?

  16. #216
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Morning hope things are ok with you. So remember yesterday you told me about this "Oh hang on, my last post might be wrong because rowName is a misleading variable name. That's the select element itself." So what is next step for this ya?

  17. #217
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Morning hope things are ok with you. So remember yesterday you told me about this "Oh hang on, my last post might be wrong because rowName is a misleading variable name. That's the select element itself." So what is next step for this ya?
    I've just got back home and am looking forward to my pillow. I'll take a look when I arise before I head out mid-morning tomorrow.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  18. #218
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    No worries you have good sleep man. Take care how is the earthquake quite settled down.

  19. #219
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    The script is checking the locationFrom select field against that of the locationTo select field, which is right and good.

    Code:
    locationToValue=$('[name^="locationTo"]', row).attr('value');
    But, check your form. We assume that there is a field that starts with locationTo, but there isn't one in the form.
    You have a mistake in your HTML content for the form. Your form has no fields that start with locationTo, which is an error that needs to be fixed.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  20. #220
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I have fixed it but I got a new error as.
    Error: $.validator.methods[method] is undefined
    Source File: http://183.78.169.54/v3/jquery.validate.js
    Line: 490

  21. #221
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    I have fixed it but I got a new error as.
    Oh no, of course - how silly.

    When passing validation rules to the validate function,we use the name of the form as a part of the rule, but that's only when defining those rules from the context of the whole form itself.

    Now that we are simplifying things so that the rule is provided from the context of the field itself, we shouldn't be using the name of the field as a part of the rule, because that's already known by the validator. Instead, it's just the rule that we pass to the validator from the context of the field.

    The rule now becomes much simpler.

    Instead of this:

    Code:
    var rule = {};
    rule[$('[name^="locationFrom"]', row).attr('name')] = {
        required: function(element) {
            ...
        }
    }
    It should instead be this:

    Code javascript:
    var rule = {
        required: function(element) {
            ...
        }
    };

    After that, we can work on comparing the correct values.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  22. #222
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Just to confirm is it that I remove this line rule[$('[name^="locationFrom"]', row).attr('name')] = { thats all?

  23. #223
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Just to confirm is it that I remove this line rule[$('[name^="locationFrom"]', row).attr('name')] = { thats all?
    No that's not all. The details of the changes are fully visible in the before/after code from the previous post.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  24. #224
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Here is the link http://183.78.169.54/v3/addRoute.php . I have close the rest of the codes. as below except the rowName. But still no validation yet.

    function matchingFromAndTo(row)
    {
    //alert("ID : "+$('[name^="locationFrom"]', row).attr('name'));
    //var rowName="";
    rowName = $('[name^="locationFrom"]', row);
    var rule = {};
    //rule[$('[name^="locationFrom"]', row).attr('name')] =
    //{
    required: function(element) {
    var row="",locationToValue="";
    row = $(element).parents('tr');
    locationToValue=$('[name^="locationTo"]', row).attr('value');
    return $(element).val()==$(element).parents('tr').find("td").eq(4).val();

    }
    //}
    $(rowName).rules('add', rule);

    }

  25. #225
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    But still no validation yet.
    There's a syntax error that's preventing any scripting from running.

    Have another look at what the updated version of the code should look like:

    Code javascript:
    var rule = {
        required: function(element) {
            ...
        }
    };
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •