Jump to content
php.lv forumi
  • 0

Jāizpilda viens vai otrs ievades lauks.


Salv

Question

Sveiki.

Vai kāds varētu palīdzēt šādā jautājumā...

Ir divas datu ievades tabulas vienā formā. Javascript funkcija pārbauda vai ir aizpildīti pirmās tabulas ievades lauki. Kāda būtu funkcija, kas pārbaudītu vai ir aizpildīts pirmais tabulas lauks tabulai nr.1 vai pirmais lauks tabulai nr.2, t.i. kļūdas paziņojums netiek izvadīts gadījumā vai ir aizpildītas vienas vai otras tabulas lauks. Un tā uz priekšu pārējiem ievades laukiem.

 

Javascript funkcija un pirmās tabulas paraugs, tāda pati ir vēl otra. Jāpārbauda ir vai ir aizpildīti vienas vai otras tabulas lauki.

 

function checkShippingAndPaymentInfo()
{
with (window.document.frmCheckout) {
 if (isEmpty(txtPaymentFirstName, 'Ievadiet vārdu')) {
  return false;
 } else if (isEmpty(txtPaymentLastName, 'Ievadiet uzvārdu')) {
  return false;
 } else if (isEmpty(txtPaymentAddress1, 'Ievadiet piegādes adresi')) {
  return false;
 } else if (isEmpty(txtPaymentMail, 'Ievadiet e-pasta adresi')) {
  return false;
 } else if (isEmpty(txtPaymentPhone, 'Ievadiet telefona numuru')) {
  return false;
 }
}
}

 

<form action="<?php echo $_SERVER['PHP_SELF']; ?>?step=2" method="post" name="frmCheckout" id="frmCheckout" onSubmit="return checkShippingAndPaymentInfo();">
<table width="550" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable">
   	<tr class="entryTableHeader">
       	<td colspan="2">Fiziskām personām</td>
   	</tr>
   	<tr>
       	<td width="150" class="label">Vārds</td>
       	<td class="content"><input name="txtPaymentFirstName" type="text" class="box" id="txtPaymentFirstName" size="30" maxlength="50"></td>
   	</tr>
   	<tr>
       	<td width="150" class="label">Uzvārds</td>
       	<td class="content"><input name="txtPaymentLastName" type="text" class="box" id="txtPaymentLastName" size="30" maxlength="50"></td>
   	</tr>
   	<tr>
       	<td width="150" class="label">Adrese</td>
       	<td class="content"><input name="txtPaymentAddress1" type="text" class="box" id="txtPaymentAddress1" size="50" maxlength="100"></td>
   	</tr>
   	<tr>
       	<td width="150" class="label">E-pasts</td>
       	<td class="content"><input name="txtPaymentMail" type="text" class="box" id="txtPaymentMail" size="30" maxlength="100"></td>
   	</tr>
   	<tr>
       	<td width="150" class="label">Telefona nr.</td>
       	<td class="content"><input name="txtPaymentPhone" type="text" class="box" id="txtPaymentPhone" size="30" maxlength="32"></td>
   	</tr>
</table>

Edited by Salv
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

No tās JS f-jas var visus else mierīgi dzēst ārā, jo pēc return tāpat nekas neizpildīsies.

 

 

Un kas notiek ja kāds no pirmajiem if neizpildās (respektīvi ja nav tukšs un viss ir ok)?

Edited by y2ok
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...