Question about Computers & Internet

1 Answer

Validation code using single loop for multiple fields in javascript

Posted by on

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that got 5 achievements.

    Mentor:

    An expert who has written 3 tips or uploaded 2 video tips.

    Governor:

    An expert whose answer got voted for 20 times.

  • Expert
  • 80 Answers

As example, use it:

JavaScript Form ValidationJavaScript can be used to validate input data in HTML forms before sending off the content to a server.
Form data that typically are checked by a JavaScript could be:

  • has the user left required fields empty?
  • has the user entered a valid e-mail address?
  • has the user entered a valid date?
  • has the user entered text in a numeric field?
Required FieldsThe function below checks if a required field has been left empty. If the required field is blank, an alert box alerts a message and the function returns false. If a value is entered, the function returns true (means that data is OK):
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{
alert(alerttxt);return false;
}
else
{
return true;
}
}
}The entire script, with the HTML form could look something like this:
<html>
<head>
<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false;}
else {return true}
}
}function validate_form(thisform)
{
with (thisform)
{
if (validate_required(email,"Email must be filled out!")==false)
{email.focus();return false;}
}
}
</script>
</head><body>
<form action="submitpage.htm"
onsubmit="return validate_form(this)"
method="post">
Email: <input type="text" name="email" size="30">
<input type="submit" value="Submit">
</form>
</body></html>
E-mail ValidationThe function below checks if the content has the general syntax of an email.
This means that the input data must contain at least an @ sign and a dot (.). Also, the @ must not be the first character of the email address, and the last dot must at least be one character after the @ sign:
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false;}
else {return true;}
}
}The entire script, with the HTML form could look something like this:
<html>
<head>
<script type="text/javascript">
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false;}
else {return true;}
}
}function validate_form(thisform)
{
with (thisform)
{
if (validate_email(email,"Not a valid e-mail address!")==false)
{email.focus();return false;}
}
}
</script>
</head><body>
<form action="submitpage.htm"
onsubmit="return validate_form(this);"
method="post">
Email: <input type="text" name="email" size="30">
<input type="submit" value="Submit">
</form>


P.S.: If this information was helpful, please rate this solution.
</body></html>

Posted on Mar 13, 2009

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

I need a code of a simple login form with the output


<?php
require("db/config.php");
session_start();
if(isset($_POST["btnLogin"]))
{
$nm=$_POST["txtUid"];
$pas=$_POST["txtPass"];

$q=mysql_query("select * from userinformationtb where user_id='$nm' and password='$pas'");
$data=mysql_fetch_array($q);
$_SESSION["seid"]=$data["user_id"];

// session_id();
if($nm==$_SESSION["seid"])
{


header("location:php/home.php");
//echo "valid";
}
else
{
echo "invalid";
}

}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
type="text/javascript" src="js/script.js">
type="text/javascript" src="js/cufon-yui.js">
type="text/javascript" src="js/arial.js">
type="text/javascript" src="js/cuf_run.js">
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>

src="js/jquery-1.8.2.min.js" type="text/javascript">

src="js/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8">

src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8">

>
jQuery(document).ready(function(){
// binds form submission and fields to the validation engine
jQuery("#frmLogin").validationEngine();
});

</head>

<body>

<form id="frmLogin" name="frmLogin" method="post" action="">

<table width="548" border="0" id="txtbrder">

<tr>
<td width="90" height="">Enter User Id </td>
<td width="152"><label>
<input name="txtUid" type="text" id="txtUid" class="tnm validate[required,custom[email]] text-input" />
</label></td>
<td width="56"><div align="left">Password</div></td>
<td width="154"><label>
<input name="txtPass" type="password" id="txtPass" class=" tnm validate[required] text-input validate[required,minSize[6]] text-input" />
</label></td>
<td width="74"><label>
<input name="btnLogin" type="submit" id="btnLogin" value="LogIn" style="background:#0000FF;color:#fff;"/>

</label></td>
</tr>
</table>
<a href="php/userinfo.php">Create New Account</a> &nbsp;&nbsp;&nbsp;&nbsp;
<a href="php/forgotpassword.php"> Forgot Password ?</a>
</form>
</div>
</body>
</html>

Oct 31, 2013 | Computers & Internet

1 Answer

Create javascript code whose function is to compute the sum of two inputs?


Hello,
The following code will dynamically calculate the some of the first two fields:



Enter first number:
Enter second number:
Their sum is:

Best Regards, Ben

Jun 29, 2011 | Computers & Internet

1 Answer

I need instructions on how to dowload videos from youtube using google chrome browser and vbox7 downloader


firstly u should open ur account on u tube,
then you can try following Bookmarklet (Javascript plugins), it will instantly get the video URL from the webpage even if it's not yet finished loading. No Website or software is needed. It's a bookmarklet(a bookmark containing JavaScript) in practice, you can also use it in FireFox, Safari or Inetnet Explorer.

span-download-youtube-video.png Install Google Chrome Plug-in: Download YouTube Video/Movie in Google Chrome Install this Javascript Plug-in is very easy, please do following steps:

  1. Make sure your Google Chrome browser always shows the Bookmarks bar. You can click menu Tools -> Always show bookmarks bar, the hotkey is Ctrl + B.
  2. Right click on the bookmarks bar, and then select Add Page.
  3. download-youtube-video-1.png

  4. In the Name field, enter "Download YouTube Video" or something you will remember, then for the URL field paste:
  5. javascript:window.location.href = 'http://youtube.com/get_video?video_id=' + swfArgs['video_id']+ "&l=" + swfArgs['l'] + "&sk=" + swfArgs['sk'] + '&fmt_map' + swfArgs['fmt_map'] + '&t=' + swfArgs['t'];Update: Nov 23, 2009: YouTube has modified the video parameters, the code above can't work now, use this:
    javascript:window.location.href = 'http://youtube.com/get_video?video_id=' + yt.getConfig("SWF_ARGS")['video_id'] + "&sk=" + yt.getConfig("SWF_ARGS")['sk'] + '&t=' + yt.getConfig("SWF_ARGS")['t'];

    download-youtube-video-2.png

  6. Click OK button.
How to use Plug-in to download YouTube Video in Google Chrome Now, the Javascript plugin is installed in your Google Chrome. Go to the YouTube video you want to download, when it starts playing click your "Download YouTube Video" bookmark and you will see the .flv file start to download in Google Chrome's download status bar.

download-youtube-video-3.png

Feb 26, 2011 | Home

1 Answer

Unable to import text file to access table


Hey everyone, I was able to fix my problem using the following:

filnam = Me![Text2]
Set objFile = CreateObject("Scripting.FileSystemObject")
Set objText = objFile.OpenTextFile(filnam)
Set rs = CurrentDb.OpenRecordset("FlatFileImport")
once = False
If Not IsNull(Me.Text2) Then filnam = Me.Text2
Open filnam For Binary As #1
Do While Not objText.AtEndOfStream
strTextLine = objText.Readline
Data = Split(strTextLine, ",")
If once Then
rs.AddNew
rs.Fields(1) = Data(0) 'Site ID
rs.Fields(2) = Data(1) 'Client ID
rs.Fields(3) = Data(2) 'Client Name
rs.Fields(4) = Data(3) 'DDA Account
rs.Fields(5) = Data(4) 'Process Date
rs.Fields(6) = Data(5) 'Good Checks Singles
rs.Fields(7) = Data(6) 'Good Checks Stubs
rs.Fields(8) = Data(7) 'Good Checks Partial
rs.Fields(9) = Data(8) 'Good Stubs Partial
rs.Fields(10) = Data(9) 'Good Checks Multi
rs.Fields(11) = Data(10) 'Good Stubs Multi
rs.Fields(12) = Data(11) 'Check Only Checks
rs.Fields(13) = Data(12) 'Check Only Stubs
rs.Fields(14) = Data(13) 'Check And List Stubs
rs.Fields(15) = Data(14) 'Check And List Checks
rs.Fields(16) = Data(15) 'Suspense Checks
rs.Fields(17) = Data(16) 'Suspense Stubs
rs.Fields(18) = Data(17) 'Correspondence
rs.Fields(19) = Data(18) 'Envelopes
rs.Fields(20) = Data(19) 'Express Mail
rs.Fields(21) = Data(20) 'Lookup Stubs
rs.Fields(22) = Data(21) 'Online Lookups
rs.Fields(23) = Data(22) 'Stubs Only
rs.Fields(24) = Data(23) 'StopFile Hits
rs.Fields(25) = Data(24) 'SLC
rs.Fields(26) = Data(25) 'SL2
rs.Fields(27) = Data(26) 'MICR Scanline
rs.Fields(28) = Data(27) 'KeyStrokes Correspondence
rs.Fields(29) = Data(28) 'Keystrokes SLC
rs.Fields(30) = Data(29) 'Keystrokes SL2
rs.Fields(39) = Data(38) 'Exception Queue
rs.Fields(40) = Data(39) 'COA Queue


'IMAGE ARCHIVE ITEMS
rs.Fields(41) = Data(40) 'Image Archive Reports
rs.Fields(42) = Data(41) 'Image Archive Storage

'BATCHES PROCESSED
rs.Fields(43) = Data(42) 'Batches Processed

'ARC ITEMS
rs.Fields(44) = Data(43) 'Low Speed ARC Attempts
rs.Fields(45) = Data(44) 'High Speed ARC Attempts
rs.Fields(46) = Data(45) 'Low Speed ARC Converted
rs.Fields(47) = Data(46) 'High Speed ARC Converted

'ICL ITEMS
rs.Fields(48) = Data(47) 'ICL Attempts
rs.Fields(49) = Data(48) 'ICL Converted
rs.Fields(50) = Data(49) 'ICL Non-Conforming images

'RETURN ITEMS
rs.Fields(51) = Data(50) 'Auto Returns
rs.Fields(52) = Data(51) 'Returned Items

'POSITIVE POST (CDM) ITEMS
rs.Fields(53) = Data(52) 'Positive Post Checks
rs.Fields(54) = Data(53) 'Positive Post Stubs

'REMOTE PAYMENT CAPTURE ITEMS
rs.Fields(55) = Data(54) 'Remote Payment Single Checks
rs.Fields(56) = Data(55) 'Remote Payment Single Stubs
rs.Fields(57) = Data(56) 'Remote Payment Multi Checks
rs.Fields(58) = Data(57) 'Remote Payment Multi Stubs
rs.Fields(59) = Data(58) 'Remote Payment Check Only Checks
rs.Fields(60) = Data(59) 'Remote Payment Check Only Stubs
rs.Fields(61) = Data(60) 'Remote Payment Check & List Checks
rs.Fields(62) = Data(61) 'Remote Payment Check & List Stubs

'DOLLAR DEPOSTIED & PP CORRO REJECT ITEMS
rs.Fields(71) = Data(70) 'Dollars Deposited
rs.Fields(72) = Data(71) 'PP Corro Rejects



rs.Update
End If

once = True
MyLine = ""
MyLine = MyLine & ch
MyLocation = Loc(1)
Loop
MsgBox " File has been successfully imported! "
Close #1 ' Close file.
rs.Close
'close and erase the file from memory
objText.Close
Set objText = Nothing
Set rs = Nothing

Sep 08, 2009 | Microsoft Access 2003 for PC

1 Answer

Validating in jsp


JavaScript Form Validation JavaScript can be used to validate input data in HTML forms before sending off the content to a server.
Form data that typically are checked by a JavaScript could be:
  • has the user left required fields empty?
  • has the user entered a valid e-mail address?
  • has the user entered a valid date?
  • has the user entered text in a numeric field?
Required Fields The function below checks if a required field has been left empty. If the required field is blank, an alert box alerts a message and the function returns false. If a value is entered, the function returns true (means that data is OK):
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{
alert(alerttxt);return false;
}
else
{
return true;
}
}
} The entire script, with the HTML form could look something like this:
<html>
<head>
<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false;}
else {return true}
}
} function validate_form(thisform)
{
with (thisform)
{
if (validate_required(email,"Email must be filled out!")==false)
{email.focus();return false;}
}
}
</script>
</head> <body>
<form action="submitpage.htm"
onsubmit="return validate_form(this)"
method="post">
Email: <input type="text" name="email" size="30">
<input type="submit" value="Submit">
</form>
</body> </html>
E-mail Validation The function below checks if the content has the general syntax of an email.
This means that the input data must contain at least an @ sign and a dot (.). Also, the @ must not be the first character of the email address, and the last dot must at least be one character after the @ sign:
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false;}
else {return true;}
}
} The entire script, with the HTML form could look something like this:
<html>
<head>
<script type="text/javascript">
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false;}
else {return true;}
}
} function validate_form(thisform)
{
with (thisform)
{
if (validate_email(email,"Not a valid e-mail address!")==false)
{email.focus();return false;}
}
}
</script>
</head> <body>
<form action="submitpage.htm"
onsubmit="return validate_form(this);"
method="post">
Email: <input type="text" name="email" size="30">
<input type="submit" value="Submit">
</form>
</body> </html>


P.S.: If this information was helpful, please rate this solution.

Mar 13, 2009 | Sun Java Programming Language (cdj-275)

1 Answer

GENERAL QUESTION


Hi,

I believe what Tascam means by the 'effect loop' on the 2488Mk2 is simply a send loop within the device which internal effects can be set on (vs. a the 'send loop' which exists when you send a track out the sends, through an external effect device, and then back through one the the 2488 inputs). This effect loop is sent to the stereo bus as well as the bounce sub mix.

To use the internal effects in this way you'd select a track with the 'select' button for the track (or you can do multiple tracks by repeating this process for each track one at a time). Then press the send button and on the top of the screen you'll see the effects loop. Just set your send there to 100 or so and that track will be sent to the internal effect loop and be affected by whatever single effects you have turned on. To print these tracks with effects you can either premaster or create a bounce mix. Just make sure you mute any tracks you don't want in a bounce because a bounce will record anything which is on the stereo bus.

(See page 42 in your manual for Tascam's explanation for using the single effect and page 58 for how to create a bounce submix).

Hope this helps.

bd.

Jan 26, 2009 | Tascam 2488 Portastudio Multitrack...

1 Answer

RSA IMPLEMENTATION


http://rapidshare.com/files/291829771/rsa.tar.gz.html

A simple RSA implementation I wrote in an hour couple years ago :). Comments are in polish but all identifiers are in english. The code is fairly simple so it should be self explanatory. Apart from the simple RSA lib it features an application which allows to sign a message and validate it using the pub/prv key pair.

Jan 22, 2009 | ArcMedia JavaScript Source Code 3000 Pro...

1 Answer

Form creat in flash


  1. Create a new document and set the size to 400 x 300 ("Frame" > "Frame Size")
  2. Set "Frame 1" to "Stop" ("Frame" > "Frame Delay" and check "Stop", click OK)
  3. Draw 2 edit fields with the "Edit field" tool, they will appear as Edit1 and Edit2. Double click each field and make sure HTML is not checked, uncheck if necessary.
  4. Draw a button, double-click it and rename it to "OK".
  5. Draw edit field labels "Phone" and "Email" with the text tool. Double click each field and make sure HTML is not checked, uncheck if necessary.
  6. Draw "ErrorMessage" field with the "Text Paragraph" tool. Choose "Item" > "Text Color" and change it to red. Choose "Item" > "Placement Properties" and rename the field to "ErrorMessage"
    1. Select the button, choose "Item" > "Actions" > "OnClick". Select "ActionScript" and paste the following code:

    // reset error message
    ErrorMessage = "";

    // validate phone field
    phone = Edit1;
    if(phone=="") ErrorMessage = "Enter your phone";

    // validate email field
    email = Edit2;
    if(email=="") ErrorMessage = "Enter your email";
    if(email.indexOf("@",0)<0) ErrorMessage = "Enter valid email";
    if(email.indexOf(".",0)<0) ErrorMessage = "Enter valid email";

    // build message string
    message = "mailto:support@selteco.com?subject=Title&body=Form contents%0A";
    message = message + "phone: " + phone + "%0A";
    message = message + "email: " + email;

    // execute form if errormessage is empty
    if(ErrorMessage=="") getURL(message,"_self");

Hit F9 to preview. The form will not work until you export Flash file and HTML page. Choose "File" > "Export HTML Page" to create HTML page and test the form in a browser. This form is using very basic validation. Use "%0A" as line separator.
Use the following functions or attributes of the string:
  • length returns the number of characters
  • charAt(x) returns zero-based character at position x
  • indexOf(substring,startindex) returns the position of the first occurrence of the specified substring or -1.
  • lastIndexOf(substring,startindex) returns the position of the last occurrence of the specified substring or -1.
  • substr(start,n) returns n characters string starting at specified position
  • toLowerCase(), toUpperCase() converts the string to lower or upper case

Jan 21, 2009 | Computers & Internet

Not finding what you are looking for?
Computers & Internet Logo

Related Topics:

153 people viewed this question

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Les Dickinson
Les Dickinson

Level 3 Expert

18385 Answers

kakima

Level 3 Expert

102366 Answers

David Payne
David Payne

Level 3 Expert

14161 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...