Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-07-2008, 04:47 PM   PM User | #1
bridgey
New to the CF scene

 
Join Date: Dec 2004
Posts: 8
Thanks: 3
Thanked 0 Times in 0 Posts
bridgey is an unknown quantity at this point
Question Validation Script Stopped Working..

Hi All

I have the following javascript in place to check form entry fields before submitting the information to a php script, which emails the info to me.

The problem is that the validation has suddenly stopped working.. it worked half an hour ago before i starting changing the script.. now doesnt. I have been trying to get the script to notice that if a form field is equal to xx, then do not allow submission of the form.

Can anyone see any errors in the below?

The page can be viewed at www.centurysoftware.co.uk/custupdate.html


Code:
<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value==""||value=xx)
  {alert(alerttxt);return false;}
else {return true}
}
}
function validate_form(form1){
with (form1){
if (validate_required(name,"Please enter your name before proceeding")==false)
  {name.focus();return false;}
if (validate_required(client,"Please enter the company name before proceeding")==false)
  {client.focus();return false;}
if (validate_required(job,"Please enter your job title before proceeding")==false)
  {job.focus();return false;}
if (validate_required(supstatus,"Please select from the following before proceeding..")==false)
  {supstatus.focus();return false;}
if (validate_required(email,"Please enter your email address before proceeding")==false)
  {email.focus();return false;}
if (validate_required(tel,"Please enter your telephone number before proceeding")==false)
  {tel.focus();return false;}
if (validate_required(servos,"Please select from the following before proceeding..")==false)
  {servos.focus();return false;}
if (validate_required(servname,"Please enter the computer name of your Sage server before proceeding")==false)
  {servname.focus();return false;}
if (validate_required(bit,"Please select from the following before proceeding..")==false)
  {bit.focus();return false;}
if (validate_required(mem,"Please select from the following before proceeding..")==false)
  {mem.focus();return false;}
if (validate_required(pro,"Please select from the following before proceeding..")==false)
  {pro.focus();return false;}
if (validate_required(sql,"Please select from the following before proceeding..")==false)
  {sql.focus();return false;}

}
}
</script>
Here is a snippet of the form in use (still called form1):-

Code:
<form name="form1" method="post" action="" onsubmit="return validate_form(this);">

            <p><span class="style6"><span class="style16">*</span> </span>Please specify the server operating system of your Sage server:<br />
              <select name="servos" id="servos" style="border:thin #000000; background-color:#E6FFDD; outline:none; font-family:tahoma; font-size:14px">
                <option value="xx" selected="selected">Please Select...</option>
                <option value="xx">&nbsp;</option>
                <option value="xx">* Windows Server 2008 Family:-</option>
                <option value="2008 Standard">Windows Server 2008 Standard Edition</option>
                <option value="2008 Enterprise">Windows Server 2008 Enterprise Edition</option>
                <option value="2008 Datacenter">Windows Server 2008 Datacenter Edition</option>
                <option value="2008 Datacenter">Windows Small Business Server 2008</option>
                <option value="xx">&nbsp;</option>
                <option value="xx">* Windows Server 2003 Family:-</option>
                <option value="2003 SBS">Windows Server 2003 Small Business Edition</option>
                <option value="2003 Standard">Windows Server 2003 Standard Edition</option>
                <option value="2003 Enterprise">Windows Server 2003 Enterprise Edition</option>
                <option value="2003 Datacenter">Windows Server 2003 Datacenter Edition</option>
                <option value="xx">&nbsp;</option>
                <option value="xx">* Windows Server 2000 Family:-</option>
                <option value="2000 Server">Windows 2000 Server</option>
                <option value="2000 Advanced Server">Windows 2000 Advanced Server</option>
                <option value="2000 Datacenter">Windows 2000 Datacenter Server</option>
                <option value="xx">&nbsp;</option>
                <option value="xx">&nbsp;</option>
                <option value="No Server (P2P)">No Server (Peer to Peer Setup)</option>
                <option value="No Server (Standalone)">No Server (Standalone Setup)</option>
              </select>
As you can see, I have used options with values of xx for display only. If any of these are selected I do not want to allow submission of the form.

Any ideas?

Many thanks in advance,
Scott
bridgey is offline   Reply With Quote
Old 08-07-2008, 04:51 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
if (value==null||value==""||value=xx)
Any clues?

PS: if xx is a string , then you need to use quotes around it.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 08-07-2008, 05:02 PM   PM User | #3
bridgey
New to the CF scene

 
Join Date: Dec 2004
Posts: 8
Thanks: 3
Thanked 0 Times in 0 Posts
bridgey is an unknown quantity at this point
I did try with the following but it didnt work - nothing changed

if (value==null||value==""||value="xx")
bridgey is offline   Reply With Quote
Old 08-07-2008, 05:06 PM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
It should be value=="xx"
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
bridgey (08-07-2008)
Old 08-07-2008, 07:09 PM   PM User | #5
bridgey
New to the CF scene

 
Join Date: Dec 2004
Posts: 8
Thanks: 3
Thanked 0 Times in 0 Posts
bridgey is an unknown quantity at this point
Thumbs up

you know, i really should stop doing 50 things at once.. maybe i would have noticed that! *embarrassed*

Thanks, works fine
bridgey is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:08 AM.


Advertisement
Log in to turn off these ads.