last day (14 days later) » 

hi
can you please add
 <button class=" btn-next" id="btn-Next" name="btn-Next">
                            Safe & next <i class="fa fa-angle-right"></i>
                        </button>
and please clcik that button
 
you should check my plnkr
please put all your stuff on the same page and avoid using post
 
yes buddy i am checking
 
this will already skip that bad request problem
 
sure thanks for that
 
10:07 AM
do it like i did, add functions on your button, and 1st, add type="button" on your button so it will not post the form anymore
 
thanks :) for that
 
np ;)
 
if (txt_otj.length > 0) {

                            alert("checkd");
                            console.log("sdf" + txt_otj);
                            $(this).rules("add","required");
                        }else{
                            alert("checking");
                            console.log("sdf" + txt_otj);
                            $(this).rules("remove","required");
                        }
could you please
check what is the problem
 
do you get an error?
txt_otj = $(".local_Field").val().length;
this is quite tricky
 
no instead
yes
 
10:10 AM
1. You have a class selector
 
which is supposed to retrieve a collection of objects
so you're using .val() on a collection
 
correct
 
$(".localField :checked") or something like this would get your data wouldn't it?
what do you want to get into your txt_otj var ?
 
1) actually what is reqquierd if i click radio button from first page it should then the button from the frist page
2) in the second page if the user not fill any of the field if he click the next button it will go to the third page
3) but if the user started fills in an y of the field it will get validated
:(
actually what is if user enter any value in the text box or select any value from the drop down

i have four fields in the second page
i have applied a common class
for all the field
so if the user select or if the user enter any of the value in the text field
the length will be greater than 0 that is what i thought
:)
then i can enable the jquery valdiator
accordingly
did you got my problem :(
 
10:19 AM
w8
 
sure
 
do you really need so many pages?
isn't it enough to make it on one page?
1. radio buttons or a select with a default "false" option selected
 
sorry @Julo0sS this was the requireemnt :(
 
ok
 
:(
 
10:37 AM
you should first echo "console.log" all the "needed vars" that you want to get & manage on each page
on page 2 for example, console.log your sessionStorage var
to check its value
then on page 3 do the same
looks like plnkr has some trouble with your POST queries...
 
yes :(
just give me an idea
    var otherObj = JSON.parse(sessionStorage.getItem('storeDate2')),
        txt_otj = $("#ipt_tstdt,#ipt_acdem").val().length,
        txt_dec = $("#txt_txtDesc,#txt_scr option").length;
 
but, server-side on your system you do not have these problems
 
is this correct
the first txt_obj that is for text field
 
looks strange...
 
and txt_dec this is for html select drop dwon
why
 
10:39 AM
try not to use .val() on collections
use .val() on a field
 
ok
but my question is how will you get the value of length
 
it's clearer and you will be able to fix where errors come from more easily
well length is number of fields
 
so instead of val()
i can directly give .length
 
for example : $('.myClass') returns a collection of items with class .myClass
even if there is only one item, it will return a collection with one field
$('.myClass').length will return the size of the array of items with .myClass
 
after your suggestion i have changed
    var otherObj = JSON.parse(sessionStorage.getItem('storeDate2')),
        txt_otj = $("#ipt_tstdt,#ipt_acdem").length,
        txt_dec = $("#txt_txtDesc,#txt_scr option").length;
 
10:45 AM
txt_otj = $("#ipt_tstdt,#ipt_acdem").length,
idk if it will work fine
but if it does
it should return 2 everytime
since you select 2 items with id
 
yes correct
 
this doesnt have real sense...
 
my question is how to check if the user enter the value in the text field or select the dropdwon
 
eventlistener
^^
 
as you told each and every time i am getting 2
 
10:48 AM
on click on the button do something like this :
$(document).on('click','#myButton',function(event){
    if($.trim($('#myTextField').val())==''){
        event.preventDefault();
        //this will prevent form to be posted
    }else{
        if($('#mySelect').val() == 'noChoice'){
            //user has to select, so prevent posting
            event.preventDefault();
        }else{
            //do whatever you want, you know your fields are ok here!
        }
    }
});
 
ok let me try buddy thanks your support :)
 
this is some kind of "validation", i think your jquery validation thing should do the same
 
if you see my plunker i am retriveing the data in the second page is that possible on load
ok
 
yes it's possible, your $(document).ready(function(){}) should do the trick
 
ok sure
 
10:53 AM
since your session data exists !
 
let me check :) thanks
yes
could you please tell me what is the use of trim here
 
trim is just here to check if user only entered white spaces
 
ok
is this correct
            } else if (otherObj.storedValue5 === "ug"){
                $('.local_Field').each(function() {
                    if($.trim($('#txt_txtDesc,#txt_scr,#ipt_tstdt,#ipt_acdem').val()) == 0){
                        $(this).rules("remove","required");
                    }else{
                        $(this).rules("add","required");
                    }
                });
            }
i changed entirely
the code like thisd
    var otherObj = JSON.parse(sessionStorage.getItem('storeDate2'));
        if (otherObj.storedValue7 === "cu") {
            $("#edu_info").hide();
                $('.local_Field').each(function() {
                    $(this).rules("remove","required");
                });
            } else if (otherObj.storedValue5 === "ug"){
                $('.local_Field').each(function() {
                    if($.trim($('#txt_txtDesc,#txt_scr,#ipt_tstdt,#ipt_acdem').val()) == 0){
                        $(this).rules("remove","required");
 
11:18 AM
no
trim will never be 0
it returns a string
so if only white spaces it should return ''
not 0
then, you should definitely do it field by field
like if ($.trim($('#txt_txtDesc'))=='' || $.trim($('#txt_src'))=='' || ...)
stop concat your fields into selectors for a while
then when everyting is working fine you shorten your code
example this code isn't working :
if($.trim($('#txt_txtDesc,#txt_scr,#ipt_tstdt,#ipt_acdem').val()) == '')
you can only trim a string
not an array of items
think you're doing many things but in the wrong order
your should care about your form validation only once you get your whole project running
forget about the "if / else" things and build the logic first
page 1 to page 2 with good data. Page 2 to page 3 with good data. & so on...
Once it works, then think about what user can do wrong (validation)
 
let me try :(
first i am trying for two text field
 
11:41 AM
this condition is correct
$( "#btn-Next" ).click(function()  {
                            alert("checking");
                             if ($.trim($('#txt_txtDesc')) == 0 || $.trim($('#txt_src')) ==  0){

                                $(this).rules("remove","required");
                            }else{
                                 $("#ipt_tstdt").find('.txt_date').removeClass("errRed");
                                $(this).rules("add","required");
                            }
                        });
== 0
it should be > =
>0
 
ok then
^^
 
i need to find whether the value is entered in the text field
if it is then do this
that is the reason i though can i give >=
>=0
 
since the $.trim is a STR (string) function i would compare its result to a string, here in this case, an empty string, so ''
but maybe it works with 0 idk
 
ok
 
the value entered in the text field is not '' since there is at least once character entered
but if only whitespaces then it returns ''
if empty, it returns ''
 
11:44 AM
yes correct as you told
if i click next button withouth filling any value
condition was working
seriously confusing buddy :(
$( "#btn-Next" ).click(function()  {
                            alert("checking");
                             if ($.trim($('#txt_txtDesc')) == "0" || $.trim($('#txt_src')) == "0"){
                                $(this).rules("add","required");
                            }else{
                                $(this).rules("remove","required");
                            }
                        });
still not working
 
lol
=>
copy paste this :
 
i put as a string
 
$( "#btn-Next" ).click(function()  {
                        alert("checking");
                         if ($.trim($('#txt_txtDesc')) == "" || $.trim($('#txt_src')) == ""){
                            $(this).rules("add","required");
                        }else{
                            $(this).rules("remove","required");
                        }
                    });
do not compare with 0
just compare with empty string :
""
 
ok :)
 
or
''
otherwise it will never work until user enters 0 into the textfield
 
11:50 AM
ok
:)
 
then what is your ".rules" function?
 
this the jquery validator
i can just give add or remove
for the validation
 
to me, your "$(this)" in the function correponds to the clicked button
not the field you intend to give properties
careful with that
 
oh yes :)
how i for got
:0
 
12:04 PM
with you guidance
            $( "#btn-Next" ).click(function()  {
                    alert("checking");
                     if ($.trim($('#txt_txtDesc')) == "" || $.trim($('#txt_src')) == "" || $.trim($('#ipt_tstdt')) == ""||$.trim($('#ipt_acdem')) == ""){
                        $("#txt_txtDesc,#txt_scr,#ipt_tstdt,#ipt_acdem").each(function() {
                                $(this).rules("remove","required");
                        });
                    }else{
                        $("#txt_txtDesc,#txt_scr,#ipt_tstdt,#ipt_acdem").each(function() {
now it was stright coming to the else part not in the if condition
 
yes
if(value is empty){}else{}
this is what it means
so if you enter something you should go straight to the else
 
now i have to do > 0 some thing like this
=> 0
 
 if ($.trim($('#txt_txtDesc')) => 0 || $.trim($('#txt_src')) => 0 || $.trim($('#ipt_tstdt')) => 0|| $.trim($('#ipt_acdem')) => 0){
 
>=
check the fiddle
compare a string which can be empty to a number will always be falsy
and if you turn it to a "0" comparison it will never be true until you really type 0
I really do not understand why you focus on compare the field data with zero
 
12:21 PM
no comparing with zero
no not comparing with zero
i want to know if atleast one value was typed in the field or select something in the drop down
it should validated
 
so this is correct then
you have 1 text field
let's call it $('#myTextField')
and a select
let's call it $('#mySelectBox')
 
ok
 
if nothing is set in the select box then its value is =0 ok?
you set a default option with value="0"
your condition is this :
 
yes
correct
<select class="required_Field slt_Field local_Field" id="txt_txtDesc" name="txt_txtDesc">
    <option value="0" selected>Please Select</option>
    <option value="2">BULATS</option>
    <option value="3">Internet Based TOEFL</option>
    <option value="4">SAT</option>
</select>
 
$(document).on('click','#validateButton',function(event){
    if(($.trim($('#myTextField').val())=='') || ($('#txt_txtDesc').val()=="0")){
        //THE FORM IS NOT VALID, TEXT FIELD EMPTY OR NO SELECT CHOSEN
    }else{
        //TEXT FIELD OK AND SELECT NOT 0 SO FORM IS VALID
    }
});
got it ? :)
 
12:27 PM
let me try buddy :)
 
got to go, feel free to write here, i'll have a look at your messages when bakc
 
sure
 
gl !
 
thanks for your supprort
:)
support
:)
hi
with this code
                 if(($('#txt_txtDesc').val()=="0") || ($.trim($('#txt_scr').val())=='') || ($.trim($('#ipt_tstdt').val())=='0') || ($.trim($('#ipt_acdem').val())=='')){
                    $(this).rules("remove","required");
                }else{
                     $(this).rules("add","required");
                }
the two drop down working fine
but not the text field :(
sorry with this
 if(($.trim($('#txt_txtDesc').val())=="0") || ($.trim($('#txt_scr').val())=='') || ($.trim($('#ipt_tstdt').val())=='0') || ($.trim($('#ipt_acdem').val())=='')){
                            $(this).rules("remove","required");
                        }else{
                             $(this).rules("add","required");
                        }
 
 
2 hours later…
2:18 PM
back
what are your text fields id's ?
 

last day (14 days later) »