livegirllove
asked on
javascript autotab and error checking
i have a form with some required fields. If the field is blank the pages pops up a warning. It works fine on "normal" fields.
On some fields I have an autotab function.
my problem is the error checking doesnt work for fields that have the autotab.
What am I doing wrong?
What does this line actually do
if(document.send_request.city.value==''){
alert('Please enter city');
document.send_request.city.focus();
return false;
On some fields I have an autotab function.
<script language="javascript" type="text/javascript">
for(var l=0; l<=2; l++){
var l1=l+1;
document.write('<input name="cvv_'+l+'" type="text" class="middletextfield" id="cvv_'+l+'" style="width:10px;" maxlength="1" onKeyup="autotab(this, document.send_request.cvv_'+l1+')"/>');
}/*send_request*/
</script>
my problem is the error checking doesnt work for fields that have the autotab.
What am I doing wrong?
What does this line actually do
var l1=l+1;
You need to set name attribute in the form, take a look as following code and its autotab function. I put javascript code for input tag between form tag, and variable "ll+1" is for the variable in autotab() function so that you keyup on first input tab and the next input tab
will be focus , so it is ll+1; 1 means next input tag
Try input something in input box 1 and keyup and then you will see next input box will be focused that is function of autotab
You can use browser developer tools click options->developer tolls->console, or Element, you can see all final code and its error.
Duncan
will be focus , so it is ll+1; 1 means next input tag
Try input something in input box 1 and keyup and then you will see next input box will be focused that is function of autotab
You can use browser developer tools click options->developer tolls->console, or Element, you can see all final code and its error.
Duncan
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AutoTab Javascript</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
function autotab(current,to){
if (current.getAttribute && current.value.length==current.getAttribute("maxlength")) {
to.focus()
}
}
</script>
<body style="width:1000px; height:1000px">
<form name="send_request">
<textarea>
This is testing
</textarea>
<script type="text/javascript">
for(var l=0; l<=2; l++){
var l1=l+1;
document.write('<input name="cvv_'+l+'" type="text" class="middletextfield" id="cvv_'+l+'" style="width:10px;" maxlength="1" onKeyup="autotab(this, document.send_request.cvv_'+l1+')"/>');
}/*send_request*/
</script>
</form>
</body>
</html>
ASKER
if(document.send_request.cvv.value==''){
alert('Please enter cvv);
document.send_request.cvv.focus();
return false;
this doesn't work.
what variable is it seeing. When I post the form the variable is $cvv but the javascript doesn't seem to be seeing that.
try review my previous post and try my example code , and you will know it,
where is your autotab funnction?
where is your autotab funnction?
ASKER
I attached the file. The autotabs are inline in the form.
The error check is in the header and does the check on submit and pops up a warning message. I don't want to rewrite this ancient terrible code I just need to know what variable I should have document.send_request.cvv. value?
document.send_request.cvv+ ll+.value
document.send_request.cvv_ .value
document.send_request.cvv+ i+.value
thanks
page08.html
The error check is in the header and does the check on submit and pops up a warning message. I don't want to rewrite this ancient terrible code I just need to know what variable I should have document.send_request.cvv.
document.send_request.cvv+
document.send_request.cvv_
document.send_request.cvv+
thanks
page08.html
I run your page that is working, I type 1 at box 1on cvv, it will go and focus to next box, so on
the autotab function is okay no error.
Where is error area you are talking ? I don't find any error and review your question post that
is not mentioned.
You need to write it in detail ,otherwise confusing
Duncan
the autotab function is okay no error.
Where is error area you are talking ? I don't find any error and review your question post that
is not mentioned.
You need to write it in detail ,otherwise confusing
Duncan
ASKER
the auto tab works. If you enter nothing in the cvv box it should popup a warning message. It does not popup the message and allows the form to submit.
If you don't enter phone number the warning works correctly.
auto tab works. error checking does not but only on fields that use autotab. credit card and cvv
If you don't enter phone number the warning works correctly.
auto tab works. error checking does not but only on fields that use autotab. credit card and cvv
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that works perfect thanks
ASKER
you are correct its wrong. but the point was I need cvv_0 etc.
Taken by itself, the line of code uses the current value of l (ell) and adds one to it. Then it assigns the resulting value to l1 (ell, one). All by itself this is not too dramatic, but if you look at the line before it, you will see that it is a for() loop iterator that initially sets l (ell) to zero. So this l1 (ell, one) variable is a pointer that looks ahead of the current value of the iterator.
* Omit these letters from your passwords, too. Especially the auto-generated passwords. And omit them from CAPTCHA images. They're more trouble than they're worth!