Script Categories













Forms >>> Check Entry.

Prevents the user from selecting a filename with a space (known to cause problems with some CGI-scripts). The visitor are informed that the field can not have spaces. Of course, you could change the character it checks for as well as the invalid alert message to something else to suit your needs.

Try to select a file with a space in it's name or in it's path!


Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function validate(){
var invalid = " "; // Invalid character is a space

if (document.submitform.filename.value.indexOf(invalid) > -1) {
alert("Sorry, spaces are not allowed.");
return false;
}
else {
return true;
   }
}
//  End -->
</script>
Try to select a file with a space in it's name or in it's path! <br><br>
<form name=submitform onSubmit="return validate()">
<input
type=file name=filename>
<br>
<input type=submit value="Submit">
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©