instead of sending me email use the issue tracker to send me messages
People
Repo info
Activity
Fox George Penguin
@olstenlarck
you do the check then you can just assign false to the result and just alert the error message
ruchirablog
@ruchirablog
thats the default format taught to us
/get variables from form and check rules/ function validate(){ // initialize local variables var errMsg = ""; // stores the error message var result = true; // assumes no errors
Fox George Penguin
@olstenlarck
and there's no need to check if err is empty string, it never won't be because you populate it in above line, huh :D
hm okey
ruchirablog
@ruchirablog
:)
Fox George Penguin
@olstenlarck
but there's absolute no logic to that valdiate function
because it does nothing
ruchirablog
@ruchirablog
yeah I can see that too
Fox George Penguin
@olstenlarck
i mean, currently it will always send the form
cuz cardmatch function wont populate the errMsg variable of the valdiate function
it make more sense to pass directly the cardmatch function
or execute cardmatch function from the valdiate function
validate*
ruchirablog
@ruchirablog
on the cardmatch function It looked like vars are not getting populated
Fox George Penguin
@olstenlarck
but yea, the problem is totally another thing
ruchirablog
@ruchirablog
so I tried this
var cardnumber = document.getElementById("cardnumber").value;
alert ("Card stored: " +cardnumber);
Fox George Penguin
@olstenlarck
missing ")"
ruchirablog
@ruchirablog
alert displays nothing
so it seems like values are not getting parsed
Fox George Penguin
@olstenlarck
yea because the syntax error
ruchirablog
@ruchirablog
element id's are right on html pages too
oh
Fox George Penguin
@olstenlarck
try to add ")" in that line alert ("Card stored: " +cardnumber);
i mean, it was missing
ruchirablog
@ruchirablog
its not different right?
I mean where should I add the ) ?
Fox George Penguin
@olstenlarck
that alert ("Card stored: " +cardnumber); was just alert ("Card stored: " +cardnumber;, so there add the ")" and try again
and one advice, dont check "falsey" values - false, undefined, null are considered as "falsey" values in javascript
so if just check given variable or property from some object it is enough in most cases to do if(sessionStorage.firstname){ instead of if(sessionStorage.firstname != undefined){
ruchirablog
@ruchirablog
thanks for the advice :) I have added the ) but still not working
error message comes up empty
I mean the alert message
Fox George Penguin
@olstenlarck
yea i see
and its because it is executed before the form is submitted
because the async nature of javascript
replace that ".onsubmit = validate" with ".onsubmit = cardmatch" it make more sense
okey okey.. wait a min :)
is there totally requirement to have validate function, are you sure?
cool
Fox George Penguin
@olstenlarck
it works haha
ruchirablog
@ruchirablog
yep it works :)
but the thing is if the error message comes up, it doesnt stop being executed
Fox George Penguin
@olstenlarck
i'll send you the code
ruchirablog
@ruchirablog
I mean if a card number starting from say 5 is entered and clicked submit
it should stop from doing anything until user enter a valid number
Fox George Penguin
@olstenlarck
yea, add return result to the cardmatch and it will works
ruchirablog
@ruchirablog
thanks a lot, I can pay you a small amount if you can help me to get everything working :)