View Full Version : Should Not Accept Blank Spaces....
serendipity
03-06-2003, 04:06 AM
Hi, I need some help "modifying" the script attached.
Previously, I had a problem with a field not accepting data entries with more than 2 blank spaces in between data...i think that has been "fixed" already...
Now I want to have a "Numbers only" field that Should NOT accept any blank spaces in between data or characters...
Note: the yellow colored fields are the fields w/c have the javascript in effect...i need to add another form/entry that is similar to it...
What do i need to add/change in the script??
Philip M
03-08-2003, 08:44 PM
Possibly no-one has bothered to answer your simple question because of your gruesome expression "Thanks in advance".
This puts me and and some others off - it simply means that you cannot be bothered to offer thanks to anyone who does choose to help you. Some find this too casual.
Try:-
<input type"text" name="NumsOnly" onblur="if(/\D/g.test(this.value)){alert ('Only integer numbers are valid in this box. '); this.focus()}" />
i.e "if something not a digit \d such as a space or a period in the string (global search) then ........."
serendipity
03-08-2003, 09:46 PM
Mr.Philip,
I apologize if you (and some others) are or may have been put off by my gruesome "sign off" - "Thanks in advance". Rest assured I make it a point to express my gratitude & appreciation to all those who help afterwards also :) Even though at times the suggestion didn't work that well...or as expected.
Anyway...I've already "resolved" (with some help from you guys) this matter for quite some time now...it's actually "mutated" to a lot more complexities since...and still does...Ok, actually, my "new" dilemma now is to make the number of digits in Cellular Phone IMSI No. field exactly equal to "just" 16 digits only - no more, no less...otherwise, the visitor should just leave it blank.
Please find attached the "updated" script, should you be interested.
Again, thanks for taking time out to reply...
Philip M
03-09-2003, 08:15 AM
function isNumeric(string){
if (string.length<16){return false}
for (x=0;x<string.length;x++){
if (!isDigit(string.charAt(x))) {
return false;
}
}
return true;
}
serendipity
03-10-2003, 03:17 AM
Thanks! It worked! I simply inserted this piece of code into my original isNumeric function:
if (string.length<16){return false}
However, i think it worked too well...coz now it will ONLY accept 16digit entries and no blank spaces allowed (w/c I did require in my previous request)...but then it got me thinking :rolleyes:...what if the user does not have any IMEI data entry (or doesnt know how to get one)...so would it be possible to have the isNumeric field be exactly a 16digit entry BUT...excludes/ignores it if the user simply leaves it blank?? is there a way around this?
You see, in the original script, none of the fields are actually required, so even if it is shaded, user can still leave it blank...however, if one did accomplish that particular field...the data entry accepts only "correct/valid" entries...otherwise it must be left blank...neat huh? and i'm a pain in the arse :)
dreamingdigital
03-10-2003, 06:15 AM
function isNumeric(string){
if (string.length==0){return null}
else if (string.length<16){return false}
for (x=0;x<string.length;x++){
if (!isDigit(string.charAt(x))) {
return false;
}
}
return true;
}
serendipity
03-11-2003, 09:45 PM
Thanks!! Worked perfectly...learned something new with that piece of code(s) inserted...i think it can be applied to every other field if needed...i guess, this piece of javascript code is now complete...at least, until i think up of some other complexities again...
Again, thanks! :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.