?
Solved

Validation

Posted on 2007-10-03
8
Medium Priority
?
167 Views
Last Modified: 2013-12-13
I need to validate the user input that equal to this number "121212"  it's number on the image
how I do that , and where I should put it Thanks

Contact us Form


<tr>
  <td >
    <font face="Arial" style="font-size: 10pt; font-style: italic" color="#111111">&nbsp;</font><font color="#FF0000" face="Arial" size="2"><b>* </b></font>
    <font face="Arial" style="font-size: 11pt; font-style: italic" color="#FF0000"><?=$aForm['tcode'][$_lang]?></font>
    <input type="text" size="7" name="fcode">     <img src="/graphic/vimage1.jpg" width="90" height="34">
  </td>
</tr>
0
Comment
Question by:usmbay
  • 3
  • 3
6 Comments
 
LVL 5

Accepted Solution

by:
frin earned 2000 total points
ID: 20009368
If you wanted to verify data upon form submission, this will do the trick:

<script>
function check() {
  if(document.getElementById('fcode').value == '121212') return true;
  else {
    alert("You didn't enter 121212!");
    return false;
  }
}
</script>
<form name="form1" onsubmit="return check();" method="post">
<table>
<tr>
  <td >
    <font face="Arial" style="font-size: 10pt; font-style: italic" color="#111111">&nbsp;</font><font color="#FF0000" face="Arial" size="2"><b>* </b></font>
    <font face="Arial" style="font-size: 11pt; font-style: italic" color="#FF0000"><?=$aForm['tcode'][$_lang]?></font>
    <input type="text" size="7" id="fcode" name="fcode">     <img src="/graphic/vimage1.jpg" width="90" height="34">
  </td>
</tr>
</table>
</form>
0
 

Author Comment

by:usmbay
ID: 20009444
sorry I miss to expalin somthing,

I have a table of imageid, and image name

now I want compare the user entry with image id
0
 

Author Comment

by:usmbay
ID: 20009474
can I return two function in onsubmit??????
like this
onsubmit="return fCheckField(0);" and "return check();">
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 5

Expert Comment

by:frin
ID: 20009717
Yes, you can use onsubmit="return fCheckField(0) && check();"
You could also call check() from fCheckField function.

This sounds like a captcha check? There's a nice solution already on net that does checking for you already: http://recaptcha.net/whyrecaptcha.html
Checking with JavaScript is not a good way to distinguish computers from people.
0
 

Author Comment

by:usmbay
ID: 20015897
<script>
function check() {
  if(document.getElementById('fcode').value == '121212') return true;
  else {
    alert("You didn't enter 121212!");
    return false;
  }
}
</script>

this code will be visible in view source code
0
 
LVL 5

Expert Comment

by:frin
ID: 20016507
Yes it will, image id will also be visible in source code. The recaptcha won't be visible.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question