validation code / function to allow only NUmbers in a text box
Answer Posted / shwetha kamath
function validate_user_editadvanced_form_username(element)
{var valid = "0123456789"
var ok = "yes";
var temp;
for (var i=0; i<element.value.length; i++) {
temp = "" + element.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry! Only numbers are accepted!");
element.focus();
element.select();
}
}
| Is This Answer Correct ? | 9 Yes | 1 No |
Post New Answer View All Answers
Code to Block submission of form by pressing Enter Key
code to images to rollover
snippet to prevent submission of form when certain/any validations got failed
code to detect availability of cookies
how to pass data between pages using Frames
how to pass data between pages using Cookies
code to detect versions of different browsers like internet explorer, netscape, mozilla, opera etc
How to encode and decode URL strings?
maximizing the main window
communication between main window and new windows
Create a Menu that can be activated while clicking on Right Mouse button
function to combine two or more arrays
how to get the User's Time of Day
create Drop-Down Navigation Menus
sample code to auto focusing the first field in a form