PC Review
Forums
Newsgroups
Microsoft Word
Microsoft Frontpage
Form Validation
Forums
Newsgroups
Microsoft Word
Microsoft Frontpage
Form Validation
![]() |
Form Validation |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I'm having some trouble validating a form. Below is a section of the validation script. There are about ten fields in the form, and a bunch of validation checks done on all of them. They all work fine except the last part shown below. (there are more checks in the actual script, I meant last one shown in this email listing)
When I ask to alert if the First_Official = Chase it doesn't do it. It just will accept any name in field whether it's Chase or something else and never alert me. If I leave field blank or use the first selection, it will alert me, so those other two checks associated with same field name are working, just not the check for "Chase" I also tried changing the script to: if (checkName != "Chase") as a test. Then it would fail and alert me no matter what name was entered. Anyone see anything wrong?? if (theForm.First_official.selectedIndex < 0) { alert("Please select a \"First Official\" option."); theForm.First_official.focus(); return (false); } if (theForm.First_official.selectedIndex == 0) { alert("The first choice for \"First Official\" is not a valid selection. Please choose one of the other options."); theForm.First_official.focus(); return (false); } // Section below not working var checkName = theForm.First_official.value; if (checkName == "Chase") { alert("The first official is Chase Please choose another names."); theForm.First_official.focus(); return (false); } |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Are you writing all of the validation by hand or is some of it being written by the FP Form Field
Validation? If you are trying to mix the FP scripts with hand written section, then you will have problems. -- ============================================== Thomas A. Rowe (Microsoft MVP - FrontPage) ============================================== If you feel your current issue is a results of installing a Service Pack or security update, please contact Microsoft Product Support Services: http://support.microsoft.com If the problem can be shown to have been caused by a security update, then there is usually no charge for the call. ============================================== "Ed Richter" <erichter1@rochester.rr.com> wrote in message news:_Blze.119953$g5.20902@twister.nyroc.rr.com... I'm having some trouble validating a form. Below is a section of the validation script. There are about ten fields in the form, and a bunch of validation checks done on all of them. They all work fine except the last part shown below. (there are more checks in the actual script, I meant last one shown in this email listing) When I ask to alert if the First_Official = Chase it doesn't do it. It just will accept any name in field whether it's Chase or something else and never alert me. If I leave field blank or use the first selection, it will alert me, so those other two checks associated with same field name are working, just not the check for "Chase" I also tried changing the script to: if (checkName != "Chase") as a test. Then it would fail and alert me no matter what name was entered. Anyone see anything wrong?? if (theForm.First_official.selectedIndex < 0) { alert("Please select a \"First Official\" option."); theForm.First_official.focus(); return (false); } if (theForm.First_official.selectedIndex == 0) { alert("The first choice for \"First Official\" is not a valid selection. Please choose one of the other options."); theForm.First_official.focus(); return (false); } // Section below not working var checkName = theForm.First_official.value; if (checkName == "Chase") { alert("The first official is Chase Please choose another names."); theForm.First_official.focus(); return (false); } |
|
|
|
#3 |
|
Guest
Posts: n/a
|
I tend to cheat. I let FP create the script, then open the file in notepad
copy and paste the sript to a blank page, close it, then remove all the validation in FP and paste the script back in. Then can customize the rest of it by hand which I was trying to do here. I added other cusomtizatio nto this script and those parts work, just not this one section. "Thomas A. Rowe" <tarowe@mvps.org> wrote in message news:uEsJ0Q3gFHA.2444@tk2msftngp13.phx.gbl... > Are you writing all of the validation by hand or is some of it being > written by the FP Form Field Validation? > > If you are trying to mix the FP scripts with hand written section, then > you will have problems. > > -- > ============================================== > Thomas A. Rowe (Microsoft MVP - FrontPage) > ============================================== > If you feel your current issue is a results of installing > a Service Pack or security update, please contact > Microsoft Product Support Services: > http://support.microsoft.com > If the problem can be shown to have been caused by a > security update, then there is usually no charge for the call. > ============================================== > > "Ed Richter" <erichter1@rochester.rr.com> wrote in message > news:_Blze.119953$g5.20902@twister.nyroc.rr.com... > I'm having some trouble validating a form. Below is a section of the > validation script. There are about ten fields in the form, and a bunch of > validation checks done on all of them. They all work fine except the last > part shown below. (there are more checks in the actual script, I meant > last one shown in this email listing) > > When I ask to alert if the First_Official = Chase it doesn't do it. It > just will accept any name in field whether it's Chase or something else > and never alert me. If I leave field blank or use the first selection, it > will alert me, so those other two checks associated with same field name > are working, just not the check for "Chase" > > I also tried changing the script to: if (checkName != "Chase") as a > test. Then it would fail and alert me no matter what name was entered. > > > Anyone see anything wrong?? > > if (theForm.First_official.selectedIndex < 0) > { > alert("Please select a \"First Official\" option."); > theForm.First_official.focus(); > return (false); > } > > if (theForm.First_official.selectedIndex == 0) > { > alert("The first choice for \"First Official\" is not a valid > selection. Please choose one of the other options."); > theForm.First_official.focus(); > return (false); > } > > // Section below not working > > var checkName = theForm.First_official.value; > if (checkName == "Chase") > { > alert("The first official is Chase Please choose another names."); > theForm.First_official.focus(); > return (false); > } > > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
If Chase is the 1st value then the test
if (theForm.First_official.selectedIndex == 0) should prevent Chase from being selected Note that the 1st selectedIndex starts numbering from 0 not 1 If Chase is not the first (say # 2 in your dropdown) then the selectedIndex would be 1, and use if (theForm.First_official.selectedIndex == 1) { alert("The official select can not be Chase - Please choose another name."); theForm.First_official.focus(); return (false); } -- _____________________________________________ SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ] "Warning - Using the F1 Key will not break anything!" (-; To find the best Newsgroup for FrontPage support see: http://www.net-sites.com/sitebuilder/newsgroups.asp _____________________________________________ "Ed Richter" <erichter1@rochester.rr.com> wrote in message news Knze.121339$g5.77485@twister.nyroc.rr.com...|I tend to cheat. I let FP create the script, then open the file in notepad | copy and paste the sript to a blank page, close it, then remove all the | validation in FP and paste the script back in. Then can customize the rest | of it by hand which I was trying to do here. I added other cusomtizatio nto | this script and those parts work, just not this one section. | | | "Thomas A. Rowe" <tarowe@mvps.org> wrote in message | news:uEsJ0Q3gFHA.2444@tk2msftngp13.phx.gbl... | > Are you writing all of the validation by hand or is some of it being | > written by the FP Form Field Validation? | > | > If you are trying to mix the FP scripts with hand written section, then | > you will have problems. | > | > -- | > ============================================== | > Thomas A. Rowe (Microsoft MVP - FrontPage) | > ============================================== | > If you feel your current issue is a results of installing | > a Service Pack or security update, please contact | > Microsoft Product Support Services: | > http://support.microsoft.com | > If the problem can be shown to have been caused by a | > security update, then there is usually no charge for the call. | > ============================================== | > | > "Ed Richter" <erichter1@rochester.rr.com> wrote in message | > news:_Blze.119953$g5.20902@twister.nyroc.rr.com... | > I'm having some trouble validating a form. Below is a section of the | > validation script. There are about ten fields in the form, and a bunch of | > validation checks done on all of them. They all work fine except the last | > part shown below. (there are more checks in the actual script, I meant | > last one shown in this email listing) | > | > When I ask to alert if the First_Official = Chase it doesn't do it. It | > just will accept any name in field whether it's Chase or something else | > and never alert me. If I leave field blank or use the first selection, it | > will alert me, so those other two checks associated with same field name | > are working, just not the check for "Chase" | > | > I also tried changing the script to: if (checkName != "Chase") as a | > test. Then it would fail and alert me no matter what name was entered. | > | > | > Anyone see anything wrong?? | > | > if (theForm.First_official.selectedIndex < 0) | > { | > alert("Please select a \"First Official\" option."); | > theForm.First_official.focus(); | > return (false); | > } | > | > if (theForm.First_official.selectedIndex == 0) | > { | > alert("The first choice for \"First Official\" is not a valid | > selection. Please choose one of the other options."); | > theForm.First_official.focus(); | > return (false); | > } | > | > // Section below not working | > | > var checkName = theForm.First_official.value; | > if (checkName == "Chase") | > { | > alert("The first official is Chase Please choose another names."); | > theForm.First_official.focus(); | > return (false); | > } | > | > | > | | |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Ed -
Are these if statements all in the same function and one of the other if statements work? If so, then the value of theForm.First_official.value isn't "Chase" (Case maybe?) or it's hitting one of the other conditions. Put some alerts "Got here1", "Got here2" etc. in the function to verify it's being called, and an alert to just display theForm.First_official.value. I think it's always a good idea to code if (checkName == "Chase") like this (or some variation): if (toUpperCase(checkName) == "CHASE") to avoid any case issues. MikeR Ed Richter wrote: > I'm having some trouble validating a form. Below is a section of the > validation script. There are about ten fields in the form, and a bunch > of validation checks done on all of them. They all work fine except the > last part shown below. (there are more checks in the actual script, I > meant last one shown in this email listing) > > When I ask to alert if the First_Official = Chase it doesn't do it. It > just will accept any name in field whether it's Chase or something else > and never alert me. If I leave field blank or use the first selection, > it will alert me, so those other two checks associated with same field > name are working, just not the check for "Chase" > > I also tried changing the script to: if (checkName != "Chase") as a > test. Then it would fail and alert me no matter what name was entered. > > Anyone see anything wrong?? > > if (theForm.First_official.selectedIndex < 0) > { > alert("Please select a \"First Official\" option."); > theForm.First_official.focus(); > return (false); > } > > if (theForm.First_official.selectedIndex == 0) > { > alert("The first choice for \"First Official\" is not a valid > selection. Please choose one of the other options."); > theForm.First_official.focus(); > return (false); > } > > // Section below not working > > var checkName = theForm.First_official.value; > if (checkName == "Chase") > { > alert("The first official is Chase Please choose another names."); > theForm.First_official.focus(); > return (false); > } > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Wel lactually they are picxking Chase fro ma drop down list, so don't see
how there could be a problem with upper/lower case issues?? Definelty it is acting like it doesn't recognize the name as being Chase, but can't figure out why?? "MikeR" <NOnf4lSPAM@pobox.com> wrote in message news:%23v0y8c7gFHA.3316@TK2MSFTNGP14.phx.gbl... > Ed - > Are these if statements all in the same function and one of the other if > statements work? If so, then the value of theForm.First_official.value > isn't "Chase" (Case maybe?) or it's hitting one of the other conditions. > > Put some alerts "Got here1", "Got here2" etc. in the function to verify > it's being called, and an alert to just display > theForm.First_official.value. > > I think it's always a good idea to code if (checkName == "Chase") like > this (or some variation): > if (toUpperCase(checkName) == "CHASE") to avoid any case issues. > MikeR > > Ed Richter wrote: >> I'm having some trouble validating a form. Below is a section of the >> validation script. There are about ten fields in the form, and a bunch >> of validation checks done on all of them. They all work fine except the >> last part shown below. (there are more checks in the actual script, I >> meant last one shown in this email listing) >> When I ask to alert if the First_Official = Chase it doesn't do it. It >> just will accept any name in field whether it's Chase or something else >> and never alert me. If I leave field blank or use the first selection, >> it will alert me, so those other two checks associated with same field >> name are working, just not the check for "Chase" >> I also tried changing the script to: if (checkName != "Chase") as a >> test. Then it would fail and alert me no matter what name was entered. >> Anyone see anything wrong?? >> if (theForm.First_official.selectedIndex < 0) >> { >> alert("Please select a \"First Official\" option."); >> theForm.First_official.focus(); >> return (false); >> } >> if (theForm.First_official.selectedIndex == 0) >> { >> alert("The first choice for \"First Official\" is not a valid >> selection. Please choose one of the other options."); >> theForm.First_official.focus(); >> return (false); >> } >> // Section below not working >> var checkName = theForm.First_official.value; >> if (checkName == "Chase") >> { >> alert("The first official is Chase Please choose another names."); >> theForm.First_official.focus(); >> return (false); >> } >> |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Ed -
Stefan's theory is a good one. You need to put some alert messages in your function to see what it's actually getting and what the flow is. There are only a few reasons your code is not performing as you think it should. In no particular order: 1. It's not getting called. 2. The value you're testing is not the value that's getting there. 3. It's hitting another condition and exiting. 4. Invalid javascript syntax. Scattering the alerts through the code should tell you what's wrong. It's a basic de-bugging technique. If there was an easy to use step-through de-bugger..... MikeR Ed Richter wrote: > Wel lactually they are picxking Chase fro ma drop down list, so don't see > how there could be a problem with upper/lower case issues?? Definelty it is > acting like it doesn't recognize the name as being Chase, but can't figure > out why?? > > > "MikeR" <NOnf4lSPAM@pobox.com> wrote in message > news:%23v0y8c7gFHA.3316@TK2MSFTNGP14.phx.gbl... > >>Ed - >>Are these if statements all in the same function and one of the other if >>statements work? If so, then the value of theForm.First_official.value >>isn't "Chase" (Case maybe?) or it's hitting one of the other conditions. >> >>Put some alerts "Got here1", "Got here2" etc. in the function to verify >>it's being called, and an alert to just display >>theForm.First_official.value. >> >>I think it's always a good idea to code if (checkName == "Chase") like >>this (or some variation): >>if (toUpperCase(checkName) == "CHASE") to avoid any case issues. >>MikeR >> >>Ed Richter wrote: >> >>>I'm having some trouble validating a form. Below is a section of the >>>validation script. There are about ten fields in the form, and a bunch >>>of validation checks done on all of them. They all work fine except the >>>last part shown below. (there are more checks in the actual script, I >>>meant last one shown in this email listing) >>> When I ask to alert if the First_Official = Chase it doesn't do it. It >>>just will accept any name in field whether it's Chase or something else >>>and never alert me. If I leave field blank or use the first selection, >>>it will alert me, so those other two checks associated with same field >>>name are working, just not the check for "Chase" >>> I also tried changing the script to: if (checkName != "Chase") as a >>>test. Then it would fail and alert me no matter what name was entered. >>> Anyone see anything wrong?? >>> if (theForm.First_official.selectedIndex < 0) >>> { >>> alert("Please select a \"First Official\" option."); >>> theForm.First_official.focus(); >>> return (false); >>> } >>> if (theForm.First_official.selectedIndex == 0) >>> { >>> alert("The first choice for \"First Official\" is not a valid >>>selection. Please choose one of the other options."); >>> theForm.First_official.focus(); >>> return (false); >>> } >>> // Section below not working >>> var checkName = theForm.First_official.value; >>> if (checkName == "Chase") >>> { >>> alert("The first official is Chase Please choose another names."); >>> theForm.First_official.focus(); >>> return (false); >>> } >>> > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

Knze.121339$g5.77485@twister.nyroc.rr.com...
