this is My Last Problem

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

24-Nov-09 00:18
Pls kindly Read the Following ASP/VBscript Code:
<Script Language="VBScript">
<%
if pn = "" then
%>
msgbox "Enter Vehicle Name First"
history.back
<% end if %>
</script>
Sir the Problem is that if user does't enter the name in to the fields then this code is showing a msgbox "Enter Vehicle name first" but other field information information is inserted into the backend.
while it shouldn't.
Pls kindly reply sooooon
My email. jasvir275500@yahoo.com
24-Nov-09 21:03
Hi there,

It's not completely clear from your post, but I think you are using this VBScript client side on the browser?

VBScript client side only works on IE. For better compatibility, you should use Javascript for form validation:
http://www.elated.com/articles/form-validation-with-javascript/

The other problem is that you should be preventing the form submit if the validation fails, which history.back will never do. Typically you'd do this with some code like this in the HTML form declaration



<form onsubmit="return validate(this)">



and then you get the validate() javascript function to return false if not valid, or true if everything's ok. Something like this:



function validate(f)
{
if (f.pn.value == "")
{
alert("Enter Vehicle Name";
return false;
}
return true;
}



Cat

[Edited by cat on 25-Nov-09 16:43]

--
http://web.soothed.com.au/
Web design for natural therapists

 
New posts
Old posts

Follow Elated