Submit the form, how to check if required field is Not empty 
Author Message
 Submit the form, how to check if required field is Not empty

Before submitting the html data below to process.asp
page, I would like to check if the required
field "firstname:" is not empty. If it is, give the
input.asp page back to the user to force him enter the
firstname. Can you clarify how could I do that using
VBScript ?

'input.asp

<HTML>
<BODY>
<FORM>

<form name="Update" method="post" action="process.asp">

firstname:*<br>
<Input id=firstname name=firstname>
Lastname:<br>
<Input id=lastname name=lastname>

 <INPUT id=UpDateAccount type=submit value="Submit"
 name="updateAccount">

</FORM>
</BODY>
</HTML>



Wed, 19 Jan 2005 23:04:19 GMT  
 Submit the form, how to check if required field is Not empty
Marlon Brown wrote on 03 Aug 2002 in microsoft.public.scripting.vbscript:

Quote:
> Before submitting the html data below to process.asp
> page, I would like to check if the required
> field "firstname:" is not empty. If it is, give the
> input.asp page back to the user to force him enter the
> firstname. Can you clarify how could I do that using
> vbscript ?

something like this ? (not tested!)

<HTML>

<script language=vbscript>
function submitit()
        if Update.firstname.value="" then
                imgbox "Firstname still empty"
        else
                Update.submit()
        end if
end function
</script>

<BODY>
<FORM>

<form name="Update" method="post" action="process.asp">

firstname:*<br>
<Input id=firstname name=firstname type=text>
Lastname:<br>
<Input id=lastname name=lastname type=text>

 <INPUT type=button value="Submit" onclick="submitit()">

</FORM>
</BODY>
</HTML>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)



Wed, 19 Jan 2005 23:30:31 GMT  
 Submit the form, how to check if required field is Not empty
Something was not working accordingly. It didn't go to
the "submitit()" function.

I made some changes. The below code displays the MsgBox
accordingly.
How can I "go to process.asp" ? The .submit() didn't work
either and using the code below even if "firstname"
and "lastname" are NOT blank, I still bet a MSgBox saying
they are blanks...

<HTML>
<HEAD>
<Script Language = VBSCRIPT>

Sub cmdMessage_onClick
       If firstname = "" Or lastname ="" Then

          MsgBox "First and Last names are required
fields.",_
                  VbOkOnly+VbExclamation,_
                  "Information Systems"

       Else

           createuser.submit()
'** This one here doesn't seem correct either. I want to
go to "process.asp. <formname>.Submit() didn't work either"

       End If

End Sub

</script>
</HEAD>

<BODY>
<FORM>

<form name="createuser" method="post" action="process.asp">

firstname:*<br>
<Input id=firstname name=firstname type=text>
Lastname:<br>
<Input id=lastname name=lastname type=text>

<Input type = "Button" Name = "cmdMessage" Value
= "Submit">

</DIV>

</Font>
</FORM>
</BODY>
</HTML>

Quote:
>-----Original Message-----
>Marlon Brown wrote on 03 Aug 2002 in

microsoft.public.scripting.vbscript:
Quote:

>> Before submitting the html data below to process.asp
>> page, I would like to check if the required
>> field "firstname:" is not empty. If it is, give the
>> input.asp page back to the user to force him enter the
>> firstname. Can you clarify how could I do that using
>> vbscript ?

>something like this ? (not tested!)

><HTML>

><script language=vbscript>
>function submitit()
>            if Update.firstname.value="" then
>                    imgbox "Firstname still empty"
>            else
>                    Update.submit()
>            end if
>end function
></script>

><BODY>
><FORM>

><form name="Update" method="post" action="process.asp">

>firstname:*<br>
><Input id=firstname name=firstname type=text>
>Lastname:<br>
><Input id=lastname name=lastname type=text>

> <INPUT type=button value="Submit" onclick="submitit()">

></FORM>
></BODY>
></HTML>

>--
>Evertjan.
>The Netherlands.
>(Please change the x'es to dots in my emailaddress)
>.



Thu, 20 Jan 2005 09:44:06 GMT  
 Submit the form, how to check if required field is Not empty
Marlon brown wrote on 04 Aug 2002 in microsoft.public.scripting.vbscript:

Quote:
> Something was not working accordingly. It didn't go to
> the "submitit()" function.

> I made some changes. The below code displays the MsgBox
> accordingly.
> How can I "go to process.asp" ? The .submit() didn't work
> either and using the code below even if "firstname"
> and "lastname" are NOT blank, I still bet a MSgBox saying
> they are blanks...

This one I tested, beware of spurious linebreaks:

<html>
<head>

<script language = "vbscript">
Sub cmdMessage_onClick

 If document.createuser.firstname.value = "" Or
document.createuser.lastname.value = "" Then
    MsgBox "First and Last names are required
fields.",VbOkOnly+VbExclamation,"Information Systems"

 Else
    document.createuser.submit
 End If
End Sub
</script>

</head>
<body>

<form name=createuser method="post" action="process.asp">
        firstname:*<br>
        <input name="firstname" type="text"><br>
        Lastname:<br>
        <input name="lastname" type="text"><br><br>
        <input type="button" Name="cmdMessage" Value="Submit now">
</form>

</body>
</html>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)



Thu, 20 Jan 2005 17:05:50 GMT  
 Submit the form, how to check if required field is Not empty
This will only work in IE right?


Quote:
> Marlon brown wrote on 04 Aug 2002 in microsoft.public.scripting.vbscript:
> > Something was not working accordingly. It didn't go to
> > the "submitit()" function.

> > I made some changes. The below code displays the MsgBox
> > accordingly.
> > How can I "go to process.asp" ? The .submit() didn't work
> > either and using the code below even if "firstname"
> > and "lastname" are NOT blank, I still bet a MSgBox saying
> > they are blanks...

> This one I tested, beware of spurious linebreaks:

> <html>
> <head>

> <script language = "vbscript">
> Sub cmdMessage_onClick

>  If document.createuser.firstname.value = "" Or
> document.createuser.lastname.value = "" Then
>     MsgBox "First and Last names are required
> fields.",VbOkOnly+VbExclamation,"Information Systems"

>  Else
>     document.createuser.submit
>  End If
> End Sub
> </script>

> </head>
> <body>

> <form name=createuser method="post" action="process.asp">
> firstname:*<br>
> <input name="firstname" type="text"><br>
> Lastname:<br>
> <input name="lastname" type="text"><br><br>
> <input type="button" Name="cmdMessage" Value="Submit now">
> </form>

> </body>
> </html>

> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)



Thu, 20 Jan 2005 22:20:27 GMT  
 Submit the form, how to check if required field is Not empty
rob wrote on 04 Aug 2002 in microsoft.public.scripting.vbscript:

Quote:
> This will only work in IE right?

Right.

I am told, that vbscript only is implemented in IE.

If you want cross platform compatibility, you can do the same in
Javascript.

But that is another story, sorry: NG.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)



Fri, 21 Jan 2005 00:25:56 GMT  
 Submit the form, how to check if required field is Not empty
How about this

Post to the same asp file.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>
<BODY>

<%

' Form variable retrieval ==========================================
DIM firstname,lastname,updateAccount,Form_Field

If request.form <> "" Then

 firstname = Request.Form("firstname")
 lastname = Request.Form("lastname")
 updateAccount = Request.Form("updateAccount")

 if firstname = "" then
 Form_Field = Form_Field & "firstname,"
 end if

 if lastname = "" then
 Form_Field = Form_Field & "lastname,"
 end if
 'if no error process the form

 If Form_Field = "" Then
 'Process for code goes here

 End If

End If
%>
<form action="filename.asp" method="post" name="Update" id="Update">
<%
'Show error if the form field is empty
 If instr(Form_Field,"firstname") Then %><font color="#FF0000"
class="error1">firstname</font><%ELSE%>firstname<%END IF%>:*<br>
<input type="text" name="firstname" id="firstname" value="<%= firstname %>">
<br>

<%'Show error if the form field is empty
  If instr(Form_Field,"lastname") Then %><font color="#FF0000"
class="error1">Lastname</font><%ELSE%>Lastname<%END IF%>:<br>
<input type="text" name="lastname" id="lastname" value="<%= lastname %>">
<input type="submit" name="updateAccount" id="UpDateAccount" value="Submit">
</FORM>
</BODY>
</HTML>


Quote:
> Before submitting the html data below to process.asp
> page, I would like to check if the required
> field "firstname:" is not empty. If it is, give the
> input.asp page back to the user to force him enter the
> firstname. Can you clarify how could I do that using
> vbscript ?

> 'input.asp

> <HTML>
> <BODY>
> <FORM>

> <form name="Update" method="post" action="process.asp">

> firstname:*<br>
> <Input id=firstname name=firstname>
> Lastname:<br>
> <Input id=lastname name=lastname>

>  <INPUT id=UpDateAccount type=submit value="Submit"
>  name="updateAccount">

> </FORM>
> </BODY>
> </HTML>



Fri, 21 Jan 2005 03:48:44 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Checking if a field value is empty or not

2. Hidden field in form not retaining it's value after submit

3. Submitting empty fields

4. checking for empty fields

5. help on checking to see if fields are empty WANTED

6. entrymacro is not started if field not empty and clicked

7. Repost: Empty form fields are being skipped

8. form validation: check for empty space?

9. Check for empty field

10. How do I make form fields in a Word 97 Form required

11. How make a field require data entry if any checkbox is checked

12. Checking for required fields

 

 
Powered by phpBB® Forum Software