JavaScript problem

Status
Not open for further replies.

woiwky

New Member
Messages
390
Reaction score
0
Points
0
If January is the default selected option, then the onchange event won't fire when you select it without selecting something else first. I would stick with the onchange event and just include a 'select one' option, but onclick works too I suppose.

Also, if you're trying to be standards compliant, then you shouldn't be using innerHTML. You'd have to use document.createTextNode() and element.appendChild() to do things the w3c way. But innerHTML is supported by all mainstream browsers I believe, so it should be fine.

And for passing the current element to a function, you can use the 'this' keyword, and 'this.form' to pass the containing form of form elements'. So for the form validation, it would just be onsubmit="return validateForm(this)".
 

anuj_web

New Member
Messages
145
Reaction score
0
Points
0
thanks woiwky

btw can u tell me how can i allow only @ and _ at the keypess event ? I want to use them along with letter and numbers(in the meail field :D)
since both of them dont have a keycode.....
I use the keypress event code mentioned above for letters and numerals..


and....

how can i use/declare more than one javascript source file for a html file ??

is it a right practice to have more than one script blocks just to add more JS source files ??


I use this code to check only numerals are enterd into a text box...when i enter some characters the last character is not cleared frm the text box...

Code:
function numonly(e,ctrl) 
{
  
var objRegExp = new RegExp("([a-z]+)");
var objRegExpr = new RegExp("([A-Z]+)");
if (ctrl.value.match(objRegExpr) || ctrl.value.match(objRegExp) || e.keyCode==16 ||e.keyCode==96 || e.keyCode==92 || e.keyCode==34 || e.keyCode==39 || (e.keyCode > 32 && e.keyCode < 48)  || (e.keyCode > 57 && e.keyCode < 65))
{ 
ctrl.value="";
ctrl.returnvalue = false;
} 
else
{
ctrl.returnvalue = true;
}
}

I call this function n the keypress event of the textbox

Code:
Onkeypress="return numonly(event,this)"
 
Last edited:

anuj_web

New Member
Messages
145
Reaction score
0
Points
0
I dont get javascript errors...just there is no output for the whole JS code I use

y so ??

How to get email thru PHP enabled for my X10hosting account ??
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
@ and _ should be 64 and 95 respectively. As for your function, if you only want to allow numbers, this should work:

Code:
function numonly(e) {
    var key = (e.which ? e.which : e.keyCode);
    if (key == 8 || key == 46) {
        return true;
    }
    key = String.fromCharCode(key)
    return /\d/.test(key);
}

And then just onkeypress="return numonly(event);" for the text field. The if statement just makes sure to always allow the user to press backspace/delete. Also, String.fromCharCode() will turn the key code into a letter and return it. So you don't have to match it against a number if you do that first.

Lastly, request an upgrade to the intermediate php config from your x10 account to get mail() to work. You should find this option in the lower left area.
 
Last edited:

anuj_web

New Member
Messages
145
Reaction score
0
Points
0
Hi,

thanks woiwky for replying..but this code is not working..i can type everything into the text box....

I found this code and it is working fine now

Code:
function numonly()
{
  if( (event.keyCode == 189 || event.keyCode == 109) ||
      (event.keyCode >= 48 && event.keyCode <= 57) || 
      (event.keyCode >= 96 && event.keyCode <= 105) ) {
    return true; }
  else {
    return false;
  }
}


Is there a limit for how many records a mysql database can store??
 
Last edited:

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
Is there a limit for how many records a mysql database can store??

You are limited by the ammount of space that you have, as well as the operating system which you have, although that really isn't a problem until you start using gigabytes of data.

http://dev.mysql.com/doc/refman/4.1/en/full-table.html

The limit for the number of rows in a table is ~4.2 billion.
http://jeremy.zawodny.com/blog/archives/000796.html

Edit: This thread is getting a little bit off the origional topic, please post a new thread if you have any more questions. The author should be able to reopen this thread if they need to.

*Closed*
 
Last edited:
Status
Not open for further replies.
Top