![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I've already created a simple method of ensuring that all form feilds are filled out before the form is submitted to an ASP page for records to be added to the data base. (Sorry about the formating, my newsreader may make it a mess!) script language="javascript" !-- function Check(form) { if (form.PersonID.value == "" || form.PersonID.value.length != 8) { alert("Please include an ID that is 8 characters"); form.PersonID.focus(); return false; } //There are more checking feilds here as well for phone number etc... { return true; } } //-- /script At the moment, that code above just makes sure that the user has entered at least 8 characters/numbers. Now what I want to do is make sure that in the PersonID feild that the user enters only an id that begins with the letter "p" (lowercase only) followed only by any 7 numbers. ie. p1234567, p7654321, p2468135 etc... How do I do this? Cheers. |
#3
| ||||||
| ||||||
|
|
I've already created a simple method of ensuring that all form feilds are filled out before the form is submitted to an ASP page for records to be added to the data base. script language="javascript" // deprecated |
|
function Check(form) { if (form.PersonID.value == "" || form.PersonID.value.length != 8) |
|
{ alert("Please include an ID that is 8 characters"); form.PersonID.focus(); return false; } //There are more checking feilds here as well for phone number etc... { return true; } } |
|
At the moment, that code above just makes sure that the user has entered at least 8 characters/numbers. |
|
Now what I want to do is make sure that in the PersonID feild that the user enters only an id that begins with the letter "p" (lowercase only) followed only by any 7 numbers. |
|
ie. p1234567, p7654321, p2468135 etc... How do I do this? |
#4
| |||
| |||
|
|
Drew wrote: I've already created a simple method of ensuring that all form feilds are filled out before the form is submitted to an ASP page for records to be added to the data base. (Sorry about the formating, my newsreader may make it a mess!) script language="javascript" !-- function Check(form) { if (form.PersonID.value == "" || form.PersonID.value.length != 8) { alert("Please include an ID that is 8 characters"); form.PersonID.focus(); return false; } //There are more checking feilds here as well for phone number etc... { return true; } } //-- /script At the moment, that code above just makes sure that the user has entered at least 8 characters/numbers. Now what I want to do is make sure that in the PersonID feild that the user enters only an id that begins with the letter "p" (lowercase only) followed only by any 7 numbers. ie. p1234567, p7654321, p2468135 etc... How do I do this? Cheers. use String.substring(from, to) so: testvar = "Hello!"; firstletter = testvar.substring(0,1); Regards, Erwin Moller |
|
Grant Wagner <gwagner (AT) agricoreunited (DOT) com |
#5
| |||
| |||
|
|
Now what I want to do is make sure that in the PersonID feild that the user enters only an id that begins with the letter "p" (lowercase only) followed only by any 7 numbers. ie. p1234567, p7654321, p2468135 etc... How do I do this? |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Thanks for the help guys! |
![]() |
| Thread Tools | |
| Display Modes | |
| |